diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index 33f8352f57..766e9c78aa 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -9,8 +9,7 @@ <% end %> - <% if User.current.allowed_to?(:log_time, @project) %> -
<%= l(:button_log_time) %> +
<%= l(:button_log_time) %> <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
@@ -25,8 +24,8 @@

<%= custom_field_tag_with_label :time_entry, value %>

<% end %> <% end %> -
- <% end %> +
+ <%= javascript_tag("$('#log_time').hide();") unless User.current.allowed_to?(:log_time, @project) %> <% if @issue.notes_addable? %>
<%= l(:field_notes) %> <%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 1762c7efd8..85001d1d2d 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -5539,14 +5539,20 @@ class IssuesControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time] get(:edit, :params => {:id => 1}) - assert_select 'input[name=?]', 'time_entry[hours]' + assert_select '#log_time' do + assert_select 'input[name=?]', 'time_entry[hours]' + end + assert_no_match /#{Regexp.quote("$('#log_time').hide();")}/, response.body 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, :params => {:id => 1}) - assert_select 'input[name=?]', 'time_entry[hours]', 0 + assert_select '#log_time' do + assert_select 'input[name=?]', 'time_entry[hours]' + end + assert_match /#{Regexp.quote("$('#log_time').hide();")}/, response.body end def test_get_edit_with_params