From 01ac064935df791ffb6a6726a0f4a5d9722c96b4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 6 Apr 2014 11:29:44 +0000 Subject: [PATCH] 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 --- lib/redmine/helpers/time_report.rb | 2 +- .../time_entry_reports_controller_test.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb index 14a09694e..bda6454eb 100644 --- a/lib/redmine/helpers/time_report.rb +++ b/lib/redmine/helpers/time_report.rb @@ -137,7 +137,7 @@ module Redmine custom_fields += TimeEntryActivityCustomField.all # 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, :joins => cf.join_for_order_statement, :format => cf.field_format, diff --git a/test/functional/time_entry_reports_controller_test.rb b/test/functional/time_entry_reports_controller_test.rb index b89b31e9d..56e23f935 100644 --- a/test/functional/time_entry_reports_controller_test.rb +++ b/test/functional/time_entry_reports_controller_test.rb @@ -99,7 +99,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase assert_equal "162.90", "%.2f" % assigns(:report).total_hours 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']) 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') @@ -109,6 +109,18 @@ class TimeEntryReportsControllerTest < ActionController::TestCase assert_response :success 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 get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"] assert_response :success