@@ -65,6 +65,12 class CustomFieldEnumeration < ActiveRecord::Base | |||||
65 | end |
|
65 | end | |
66 | end |
|
66 | end | |
67 |
|
67 | |||
|
68 | def self.fields_for_order_statement(table=nil) | |||
|
69 | table ||= table_name | |||
|
70 | columns = ['position'] | |||
|
71 | columns.uniq.map {|field| "#{table}.#{field}"} | |||
|
72 | end | |||
|
73 | ||||
68 | private |
|
74 | private | |
69 |
|
75 | |||
70 | def set_position |
|
76 | def set_position |
@@ -281,6 +281,32 class IssuesControllerTest < ActionController::TestCase | |||||
281 | assert_not_nil assigns(:issue_count_by_group) |
|
281 | assert_not_nil assigns(:issue_count_by_group) | |
282 | end |
|
282 | end | |
283 |
|
283 | |||
|
284 | def test_index_with_query_grouped_by_key_value_custom_field | |||
|
285 | cf = IssueCustomField.create!(:name => 'Key', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'enumeration') | |||
|
286 | cf.enumerations << valueb = CustomFieldEnumeration.new(:name => 'Value B', :position => 1) | |||
|
287 | cf.enumerations << valuea = CustomFieldEnumeration.new(:name => 'Value A', :position => 2) | |||
|
288 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => valueb.id) | |||
|
289 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => valueb.id) | |||
|
290 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => valuea.id) | |||
|
291 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '') | |||
|
292 | ||||
|
293 | get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}" | |||
|
294 | assert_response :success | |||
|
295 | assert_template 'index' | |||
|
296 | assert_not_nil assigns(:issues) | |||
|
297 | assert_not_nil assigns(:issue_count_by_group) | |||
|
298 | ||||
|
299 | assert_select 'tr.group', 3 | |||
|
300 | assert_select 'tr.group' do | |||
|
301 | assert_select 'span.name', :text => 'Value B' | |||
|
302 | assert_select 'span.count', :text => '2' | |||
|
303 | end | |||
|
304 | assert_select 'tr.group' do | |||
|
305 | assert_select 'span.name', :text => 'Value A' | |||
|
306 | assert_select 'span.count', :text => '1' | |||
|
307 | end | |||
|
308 | end | |||
|
309 | ||||
284 | def test_index_with_query_grouped_by_user_custom_field |
|
310 | def test_index_with_query_grouped_by_user_custom_field | |
285 | cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user') |
|
311 | cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user') | |
286 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2') |
|
312 | CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2') |
General Comments 0
You need to be logged in to leave comments.
Login now