Skip to content

Commit

Permalink
Merged r15224 (#22178).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15227 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Mar 13, 2016
1 parent d09b080 commit 65e2e93
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/custom_field_enumeration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def self.update_each(custom_field, attributes)
end
end

def self.fields_for_order_statement(table=nil)
table ||= table_name
columns = ['position']
columns.uniq.map {|field| "#{table}.#{field}"}
end

private

def set_position
Expand Down
26 changes: 26 additions & 0 deletions test/functional/issues_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@ def test_index_with_query_grouped_by_list_custom_field
assert_not_nil assigns(:issue_count_by_group)
end

def test_index_with_query_grouped_by_key_value_custom_field
cf = IssueCustomField.create!(:name => 'Key', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'enumeration')
cf.enumerations << valueb = CustomFieldEnumeration.new(:name => 'Value B', :position => 1)
cf.enumerations << valuea = CustomFieldEnumeration.new(:name => 'Value A', :position => 2)
CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => valueb.id)
CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => valueb.id)
CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => valuea.id)
CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')

get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
assert_response :success
assert_template 'index'
assert_not_nil assigns(:issues)
assert_not_nil assigns(:issue_count_by_group)

assert_select 'tr.group', 3
assert_select 'tr.group' do
assert_select 'span.name', :text => 'Value B'
assert_select 'span.count', :text => '2'
end
assert_select 'tr.group' do
assert_select 'span.name', :text => 'Value A'
assert_select 'span.count', :text => '1'
end
end

def test_index_with_query_grouped_by_user_custom_field
cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
Expand Down

0 comments on commit 65e2e93

Please sign in to comment.