From e21f60d17012ada6ca48cba2c3bdc7cc4ad29755 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 25 Nov 2011 21:58:09 +0000 Subject: [PATCH] Fixed: log time form not displayed on issue edit with :log_time permission only (#9405). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7924 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/issues/_edit.html.erb | 2 +- test/functional/issues_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index 010011fe8..07090c98b 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -15,7 +15,7 @@ <%= render :partial => (@edit_allowed ? 'form' : 'form_update'), :locals => {:f => f} %> <% end %> - <% if authorize_for('timelog', 'edit') %> + <% if User.current.allowed_to?(:log_time, @project) %>
<%= l(:button_log_time) %> <% fields_for :time_entry, @time_entry, { :builder => TabularFormBuilder, :lang => current_language} do |time_entry| %>
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 017f47451..8044ead12 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1195,6 +1195,22 @@ class IssuesControllerTest < ActionController::TestCase :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} } end + def test_get_edit_should_display_the_time_entry_form_with_log_time_permission + @request.session[:user_id] = 2 + Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time] + + get :edit, :id => 1 + assert_tag 'input', :attributes => {:name => 'time_entry[hours]'} + end + + def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission + @request.session[:user_id] = 2 + Role.find_by_name('Manager').remove_permission! :log_time + + get :edit, :id => 1 + assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'} + end + def test_get_edit_with_params @request.session[:user_id] = 2 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },