Skip to content

Commit

Permalink
Added all list and boolean custom data fields to the Time Report. #4077
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2951 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Oct 21, 2009
1 parent 37d401a commit 2e0cbd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/controllers/timelog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ def report
: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_criterias["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)",
:format => cf.field_format,
:label => cf.name}
end

@criterias = params[:criterias] || []
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
@criterias.uniq!
Expand Down
6 changes: 4 additions & 2 deletions test/functional/timelog_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ def test_report_at_issue_level
end

def test_report_custom_field_criteria
get :report, :project_id => 1, :criterias => ['project', 'cf_1']
get :report, :project_id => 1, :criterias => ['project', 'cf_1', 'cf_7']
assert_response :success
assert_template 'report'
assert_not_nil assigns(:total_hours)
assert_not_nil assigns(:criterias)
assert_equal 2, assigns(:criterias).size
assert_equal 3, assigns(:criterias).size
assert_equal "162.90", "%.2f" % assigns(:total_hours)
# Custom field column
assert_tag :tag => 'th', :content => 'Database'
Expand All @@ -252,6 +252,8 @@ def test_report_custom_field_criteria
:sibling => { :tag => 'td', :attributes => { :class => 'hours' },
:child => { :tag => 'span', :attributes => { :class => 'hours hours-int' },
:content => '1' }}
# Second custom field column
assert_tag :tag => 'th', :content => 'Billable'
end

def test_report_one_criteria_no_result
Expand Down

0 comments on commit 2e0cbd2

Please sign in to comment.