diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-03-12 18:43:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-03-12 18:43:19 +0000 |
commit | adbe164246ddef6dd022317a6793158c8fddefc0 (patch) | |
tree | 1e74185213d0f052d55d4ac9f66dc438d29cec08 /test/unit | |
parent | 1852d907ba5ff4951eb4783c31862dfce5f87d2b (diff) | |
download | redmine-adbe164246ddef6dd022317a6793158c8fddefc0.tar.gz redmine-adbe164246ddef6dd022317a6793158c8fddefc0.zip |
Fixing tests (sort refactoring).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2577 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/helpers/sort_helper_test.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/unit/helpers/sort_helper_test.rb b/test/unit/helpers/sort_helper_test.rb index 9132beb21..d2aca110a 100644 --- a/test/unit/helpers/sort_helper_test.rb +++ b/test/unit/helpers/sort_helper_test.rb @@ -20,6 +20,11 @@ require File.dirname(__FILE__) + '/../../test_helper' class SortHelperTest < HelperTestCase
include SortHelper
+ def setup
+ @session = nil
+ @sort_param = nil
+ end
+
def test_default_sort_clause_with_array
sort_init 'attr1', 'desc'
sort_update(['attr1', 'attr2'])
@@ -34,6 +39,13 @@ class SortHelperTest < HelperTestCase assert_equal 'table1.attr1 DESC', sort_clause
end
+ def test_default_sort_clause_with_multiple_columns
+ sort_init 'attr1', 'desc'
+ sort_update({'attr1' => ['table1.attr1', 'table1.attr2'], 'attr2' => 'table2.attr2'})
+
+ assert_equal 'table1.attr1 DESC, table1.attr2 DESC', sort_clause
+ end
+
def test_params_sort
@sort_param = 'attr1,attr2:desc'
@@ -45,13 +57,13 @@ class SortHelperTest < HelperTestCase end
def test_invalid_params_sort
- @sort_param = 'attr3'
+ @sort_param = 'invalid_key'
sort_init 'attr1', 'desc'
sort_update({'attr1' => 'table1.attr1', 'attr2' => 'table2.attr2'})
- assert_nil sort_clause
- assert_equal '', @session['foo_bar_sort']
+ assert_equal 'table1.attr1 DESC', sort_clause
+ assert_equal 'attr1:desc', @session['foo_bar_sort']
end
def test_invalid_order_params_sort
|