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) && !cf.multiple?}.each do |cf|
@available_criteria["cf_#{cf.id}"] = {:sql => cf.group_statement,
:joins => cf.join_for_order_statement,
:format => cf.field_format,
assert_equal "162.90", "%.2f" % assigns(:report).total_hours
end
- def test_report_custom_field_criteria_with_multiple_values
+ def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2'])
entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today)
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1')
assert_response :success
end
+ def test_report_multiple_values_custom_fields_should_not_be_proposed
+ TimeEntryCustomField.create!(:name => 'Single', :field_format => 'list', :possible_values => ['value1', 'value2'])
+ TimeEntryCustomField.create!(:name => 'Multi', :field_format => 'list', :multiple => true, :possible_values => ['value1', 'value2'])
+
+ get :report, :project_id => 1
+ assert_response :success
+ assert_select 'select[name=?]', 'criteria[]' do
+ assert_select 'option', :text => 'Single'
+ assert_select 'option', :text => 'Multi', :count => 0
+ end
+ end
+
def test_report_one_day
get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]
assert_response :success