From 60134152e8528034ceb07f599b4dc68969aae931 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 6 Dec 2020 03:15:54 +0200 Subject: [PATCH 1/2] Do not display in issue edit page spent time custom fields not visible by the user --- app/views/issues/_edit.html.erb | 2 +- test/functional/issues_controller_test.rb | 35 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index 33f8352f5..954f606f3 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -21,7 +21,7 @@

<%= time_entry.text_field :comments, :size => 60 %>

- <% @time_entry.custom_field_values.each do |value| %> + <% @time_entry.editable_custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :time_entry, value %>

<% end %> <% end %> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 91d11c6c8..45217b696 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -5658,6 +5658,41 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'span.icon-warning[title=?]', reason, :text => reason end + def test_get_edit_should_display_visible_spent_time_custom_field + @request.session[:user_id] = 2 + + get( + :edit, + :params => { + :id => 13, + } + ) + + assert_response :success + + assert_select '#issue-form select.cf_10', 1 + end + + def test_get_edit_should_not_display_spent_time_custom_field_not_visible + cf = TimeEntryCustomField.find(10) + cf.visible = false + cf.role_ids = [1] + cf.save! + + @request.session[:user_id] = 2 + + get( + :edit, + :params => { + :id => 13, + } + ) + + assert_response :success + + assert_select '#issue-form select.cf_10', 0 + end + def test_update_form_for_existing_issue @request.session[:user_id] = 2 patch( -- 2.22.0