From 2e0cbd2840ffb9fdb355ed0afd6b8684f2549bc7 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 21 Oct 2009 22:34:57 +0000 Subject: [PATCH] Added all list and boolean custom data fields to the Time Report. #4077 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2951 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/timelog_controller.rb | 9 ++++++++- test/functional/timelog_controller_test.rb | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index ca3774bc9..f53ea72fa 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -67,7 +67,14 @@ class TimelogController < ApplicationController :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! diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 01ca505a0..d689e9e8a 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -238,12 +238,12 @@ class TimelogControllerTest < ActionController::TestCase 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' @@ -252,6 +252,8 @@ class TimelogControllerTest < ActionController::TestCase :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 -- 2.39.5