Exclude custom fields with multiple values from time report criteria (#16519).

git-svn-id: http://svn.redmine.org/redmine/trunk@13055 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-04-06 11:29:44 +00:00
parent 22b2a1f699
commit 01ac064935
2 changed files with 14 additions and 2 deletions

View File

@ -137,7 +137,7 @@ module Redmine
custom_fields += TimeEntryActivityCustomField.all custom_fields += TimeEntryActivityCustomField.all
# Add list and boolean custom fields as available criteria # Add list and boolean custom fields as available criteria
custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| custom_fields.select {|cf| %w(list bool).include?(cf.field_format) && !cf.multiple?}.each do |cf|
@available_criteria["cf_#{cf.id}"] = {:sql => cf.group_statement, @available_criteria["cf_#{cf.id}"] = {:sql => cf.group_statement,
:joins => cf.join_for_order_statement, :joins => cf.join_for_order_statement,
:format => cf.field_format, :format => cf.field_format,

View File

@ -99,7 +99,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
assert_equal "162.90", "%.2f" % assigns(:report).total_hours assert_equal "162.90", "%.2f" % assigns(:report).total_hours
end end
def test_report_custom_field_criteria_with_multiple_values def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2']) field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2'])
entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today) entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today)
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1') CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1')
@ -109,6 +109,18 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
assert_response :success assert_response :success
end end
def test_report_multiple_values_custom_fields_should_not_be_proposed
TimeEntryCustomField.create!(:name => 'Single', :field_format => 'list', :possible_values => ['value1', 'value2'])
TimeEntryCustomField.create!(:name => 'Multi', :field_format => 'list', :multiple => true, :possible_values => ['value1', 'value2'])
get :report, :project_id => 1
assert_response :success
assert_select 'select[name=?]', 'criteria[]' do
assert_select 'option', :text => 'Single'
assert_select 'option', :text => 'Multi', :count => 0
end
end
def test_report_one_day def test_report_one_day
get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"] get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]
assert_response :success assert_response :success