@@ -138,21 +138,21 module Redmine | |||
|
138 | 138 | # Add list and boolean custom fields as available criteria |
|
139 | 139 | custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) |
|
140 | 140 | custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| |
|
141 | @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)", | |
|
141 | @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)", | |
|
142 | 142 | :format => cf.field_format, |
|
143 | 143 | :label => cf.name} |
|
144 | 144 | end if @project |
|
145 | 145 | |
|
146 | 146 | # Add list and boolean time entry custom fields |
|
147 | 147 | TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| |
|
148 | @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)", | |
|
148 | @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)", | |
|
149 | 149 | :format => cf.field_format, |
|
150 | 150 | :label => cf.name} |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | # Add list and boolean time entry activity custom fields |
|
154 | 154 | TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| |
|
155 | @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)", | |
|
155 | @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)", | |
|
156 | 156 | :format => cf.field_format, |
|
157 | 157 | :label => cf.name} |
|
158 | 158 | end |
@@ -80,6 +80,16 class TimeEntryReportsControllerTest < ActionController::TestCase | |||
|
80 | 80 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | def test_report_custom_field_criteria_with_multiple_values | |
|
84 | field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2']) | |
|
85 | entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today) | |
|
86 | CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1') | |
|
87 | CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value2') | |
|
88 | ||
|
89 | get :report, :project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"] | |
|
90 | assert_response :success | |
|
91 | end | |
|
92 | ||
|
83 | 93 | def test_report_one_day |
|
84 | 94 | get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["member", "activity"] |
|
85 | 95 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now