From: Jean-Philippe Lang Date: Sun, 17 Jun 2012 08:56:11 +0000 (+0000) Subject: Merged r9831 from trunk. X-Git-Tag: 2.0.3~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f6289d6be36a7f3f00778d226df444cdc2db5aa;p=redmine.git Merged r9831 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9843 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb index 7955c0d12..80e60529e 100644 --- a/lib/redmine/helpers/time_report.rb +++ b/lib/redmine/helpers/time_report.rb @@ -138,21 +138,21 @@ module Redmine # Add list and boolean custom fields as available criteria custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| - @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id)", + @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id ORDER BY c.value LIMIT 1)", :format => cf.field_format, :label => cf.name} end if @project # Add list and boolean time entry custom fields TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| - @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)", + @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id ORDER BY c.value LIMIT 1)", :format => cf.field_format, :label => cf.name} end # Add list and boolean time entry activity custom fields TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| - @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id)", + @available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id ORDER BY c.value LIMIT 1)", :format => cf.field_format, :label => cf.name} end diff --git a/test/functional/time_entry_reports_controller_test.rb b/test/functional/time_entry_reports_controller_test.rb index 44a5037d8..9803160f5 100644 --- a/test/functional/time_entry_reports_controller_test.rb +++ b/test/functional/time_entry_reports_controller_test.rb @@ -80,6 +80,16 @@ class TimeEntryReportsControllerTest < ActionController::TestCase assert_equal "162.90", "%.2f" % assigns(:report).total_hours end + def test_report_custom_field_criteria_with_multiple_values + 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') + CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value2') + + get :report, :project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"] + assert_response :success + end + def test_report_one_day get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["member", "activity"] assert_response :success