@@ -127,13 +127,16 module Redmine | |||||
127 | :label => :label_issue} |
|
127 | :label => :label_issue} | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | # Add list and boolean custom fields as available criteria |
|
130 | # Add time entry custom fields | |
131 | custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) |
|
131 | custom_fields = TimeEntryCustomField.all | |
132 |
# Add |
|
132 | # Add project custom fields | |
133 |
custom_fields += |
|
133 | custom_fields += ProjectCustomField.all | |
134 |
# Add |
|
134 | # Add issue custom fields | |
|
135 | custom_fields += (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) | |||
|
136 | # Add time entry activity custom fields | |||
135 | custom_fields += TimeEntryActivityCustomField.all |
|
137 | custom_fields += TimeEntryActivityCustomField.all | |
136 |
|
138 | |||
|
139 | # Add list and boolean custom fields as available criteria | |||
137 | custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| |
|
140 | custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| | |
138 | @available_criteria["cf_#{cf.id}"] = {:sql => "#{cf.join_alias}.value", |
|
141 | @available_criteria["cf_#{cf.id}"] = {:sql => "#{cf.join_alias}.value", | |
139 | :joins => cf.join_for_order_statement, |
|
142 | :joins => cf.join_for_order_statement, |
@@ -125,22 +125,36 class TimeEntryReportsControllerTest < ActionController::TestCase | |||||
125 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'} |
|
125 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'} | |
126 | end |
|
126 | end | |
127 |
|
127 | |||
128 |
def test_report_custom_field |
|
128 | def test_report_should_propose_association_custom_fields | |
129 | get :report, :project_id => 1, :criteria => ['project', 'cf_1', 'cf_7'] |
|
129 | get :report | |
|
130 | assert_response :success | |||
|
131 | assert_template 'report' | |||
|
132 | ||||
|
133 | assert_select 'select[name=?]', 'criteria[]' do | |||
|
134 | assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found' | |||
|
135 | assert_select 'option[value=cf_3]', {:text => 'Development status'}, 'Project custom field not found' | |||
|
136 | assert_select 'option[value=cf_7]', {:text => 'Billable'}, 'TimeEntryActivity custom field not found' | |||
|
137 | end | |||
|
138 | end | |||
|
139 | ||||
|
140 | def test_report_with_association_custom_fields | |||
|
141 | get :report, :criteria => ['cf_1', 'cf_3', 'cf_7'] | |||
130 | assert_response :success |
|
142 | assert_response :success | |
131 | assert_template 'report' |
|
143 | assert_template 'report' | |
132 | assert_not_nil assigns(:report) |
|
144 | assert_not_nil assigns(:report) | |
133 | assert_equal 3, assigns(:report).criteria.size |
|
145 | assert_equal 3, assigns(:report).criteria.size | |
134 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours |
|
146 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours | |
135 | # Custom field column |
|
147 | ||
136 | assert_tag :tag => 'th', :content => 'Database' |
|
148 | # Custom fields columns | |
|
149 | assert_select 'th', :text => 'Database' | |||
|
150 | assert_select 'th', :text => 'Development status' | |||
|
151 | assert_select 'th', :text => 'Billable' | |||
|
152 | ||||
137 | # Custom field row |
|
153 | # Custom field row | |
138 | assert_tag :tag => 'td', :content => 'MySQL', |
|
154 | assert_select 'tr' do | |
139 | :sibling => { :tag => 'td', :attributes => { :class => 'hours' }, |
|
155 | assert_select 'td', :text => 'MySQL' | |
140 | :child => { :tag => 'span', :attributes => { :class => 'hours hours-int' }, |
|
156 | assert_select 'td.hours', :text => '1.00' | |
141 | :content => '1' }} |
|
157 | end | |
142 | # Second custom field column |
|
|||
143 | assert_tag :tag => 'th', :content => 'Billable' |
|
|||
144 | end |
|
158 | end | |
145 |
|
159 | |||
146 | def test_report_one_criteria_no_result |
|
160 | def test_report_one_criteria_no_result |
General Comments 0
You need to be logged in to leave comments.
Login now