Makes project custom fields available on spent time report (#1766).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11459 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3269fab34e
commit
85b872f340
@ -127,13 +127,16 @@ module Redmine
|
|||||||
:label => :label_issue}
|
:label => :label_issue}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add list and boolean custom fields as available criteria
|
# Add time entry custom fields
|
||||||
custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
custom_fields = TimeEntryCustomField.all
|
||||||
# Add list and boolean time entry custom fields
|
# Add project custom fields
|
||||||
custom_fields += TimeEntryCustomField.all
|
custom_fields += ProjectCustomField.all
|
||||||
# Add list and boolean time entry activity custom fields
|
# Add issue custom fields
|
||||||
|
custom_fields += (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
||||||
|
# Add time entry activity custom fields
|
||||||
custom_fields += TimeEntryActivityCustomField.all
|
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 }.each do |cf|
|
||||||
@available_criteria["cf_#{cf.id}"] = {:sql => "#{cf.join_alias}.value",
|
@available_criteria["cf_#{cf.id}"] = {:sql => "#{cf.join_alias}.value",
|
||||||
:joins => cf.join_for_order_statement,
|
:joins => cf.join_for_order_statement,
|
||||||
|
@ -125,22 +125,36 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
|
|||||||
:attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'}
|
:attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_report_custom_field_criteria
|
def test_report_should_propose_association_custom_fields
|
||||||
get :report, :project_id => 1, :criteria => ['project', 'cf_1', 'cf_7']
|
get :report
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'report'
|
||||||
|
|
||||||
|
assert_select 'select[name=?]', 'criteria[]' do
|
||||||
|
assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found'
|
||||||
|
assert_select 'option[value=cf_3]', {:text => 'Development status'}, 'Project custom field not found'
|
||||||
|
assert_select 'option[value=cf_7]', {:text => 'Billable'}, 'TimeEntryActivity custom field not found'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_report_with_association_custom_fields
|
||||||
|
get :report, :criteria => ['cf_1', 'cf_3', 'cf_7']
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'report'
|
assert_template 'report'
|
||||||
assert_not_nil assigns(:report)
|
assert_not_nil assigns(:report)
|
||||||
assert_equal 3, assigns(:report).criteria.size
|
assert_equal 3, assigns(:report).criteria.size
|
||||||
assert_equal "162.90", "%.2f" % assigns(:report).total_hours
|
assert_equal "162.90", "%.2f" % assigns(:report).total_hours
|
||||||
# Custom field column
|
|
||||||
assert_tag :tag => 'th', :content => 'Database'
|
# Custom fields columns
|
||||||
|
assert_select 'th', :text => 'Database'
|
||||||
|
assert_select 'th', :text => 'Development status'
|
||||||
|
assert_select 'th', :text => 'Billable'
|
||||||
|
|
||||||
# Custom field row
|
# Custom field row
|
||||||
assert_tag :tag => 'td', :content => 'MySQL',
|
assert_select 'tr' do
|
||||||
:sibling => { :tag => 'td', :attributes => { :class => 'hours' },
|
assert_select 'td', :text => 'MySQL'
|
||||||
:child => { :tag => 'span', :attributes => { :class => 'hours hours-int' },
|
assert_select 'td.hours', :text => '1.00'
|
||||||
:content => '1' }}
|
end
|
||||||
# Second custom field column
|
|
||||||
assert_tag :tag => 'th', :content => 'Billable'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_report_one_criteria_no_result
|
def test_report_one_criteria_no_result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user