summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-11 16:33:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-11 16:33:51 +0000
commit3a28848ca03ae7d7e02c1bc9373a9f373cf0efeb (patch)
treebc5fd2f13bec04e46bc9b0aa71c784dfe90cb865 /test
parent1ca69f2af1eb152264fa0b0493f5173900da2f08 (diff)
downloadredmine-3a28848ca03ae7d7e02c1bc9373a9f373cf0efeb.tar.gz
redmine-3a28848ca03ae7d7e02c1bc9373a9f373cf0efeb.zip
Ability to sort the issue list by text, list, date and boolean custom fields (#1139).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2257 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index ac3e3cadc..f4b25e51b 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -175,6 +175,32 @@ class QueryTest < Test::Unit::TestCase
assert q.has_column?(c)
end
+ def test_sort_by_string_custom_field_asc
+ q = Query.new
+ c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
+ assert c
+ assert c.sortable
+ issues = Issue.find :all,
+ :include => [ :assigned_to, :status, :tracker, :project, :priority ],
+ :conditions => q.statement,
+ :order => "#{c.sortable} ASC"
+ values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
+ assert_equal values.sort, values
+ end
+
+ def test_sort_by_string_custom_field_desc
+ q = Query.new
+ c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
+ assert c
+ assert c.sortable
+ issues = Issue.find :all,
+ :include => [ :assigned_to, :status, :tracker, :project, :priority ],
+ :conditions => q.statement,
+ :order => "#{c.sortable} DESC"
+ values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
+ assert_equal values.sort.reverse, values
+ end
+
def test_label_for
q = Query.new
assert_equal 'assigned_to', q.label_for('assigned_to_id')