1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-06 15:41:33 +00:00

Only allow the use of visible custom fields in time entry reports (#29162).

Patch by Holger Just.


git-svn-id: http://svn.redmine.org/redmine/trunk@17446 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2018-07-12 21:58:22 +00:00
parent cfae2f9037
commit 391bc8b763
2 changed files with 16 additions and 4 deletions

View File

@ -129,13 +129,13 @@ module Redmine
}
# Add time entry custom fields
custom_fields = TimeEntryCustomField.all
custom_fields = TimeEntryCustomField.visible
# Add project custom fields
custom_fields += ProjectCustomField.all
custom_fields += ProjectCustomField.visible
# Add issue custom fields
custom_fields += (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
custom_fields += @project.nil? ? IssueCustomField.visible.for_all : @project.all_issue_custom_fields.visible
# Add time entry activity custom fields
custom_fields += TimeEntryActivityCustomField.all
custom_fields += TimeEntryActivityCustomField.visible
# Add list and boolean custom fields as available criteria
custom_fields.select {|cf| %w(list bool).include?(cf.field_format) && !cf.multiple?}.each do |cf|

View File

@ -135,6 +135,18 @@ class TimelogReportTest < Redmine::ControllerTest
end
end
def test_hidden_custom_fields_should_not_be_proposed
TimeEntryCustomField.create!(name: 'shown', field_format: 'list', possible_values: ['value1', 'value2'], visible: true)
TimeEntryCustomField.create!(name: 'Hidden', field_format: 'list', possible_values: ['value1', 'value2'], visible: false)
get :report, :params => {:project_id => 1}
assert_response :success
assert_select 'select[name=?]', 'criteria[]' do
assert_select 'option', :text => 'Shown'
assert_select 'option', :text => 'Hidden', :count => 0
end
end
def test_report_one_day
get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]}
assert_response :success