]> source.dussan.org Git - redmine.git/commitdiff
Don't fail if new filter is added.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Feb 2013 09:12:21 +0000 (09:12 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Feb 2013 09:12:21 +0000 (09:12 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11401 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/helpers/queries_helper_test.rb

index 81604a38b6b8add33bc8ec40a7b5f0f1dd74113f..df6da519cc2a0b0812131892ef6c100d3bb5c4f0 100644 (file)
@@ -30,18 +30,20 @@ class QueriesHelperTest < ActionView::TestCase
            :custom_fields_trackers
 
   def test_filters_options_should_be_ordered
-    User.current = User.find_by_login('admin')
-    query = IssueQuery.new(:project => nil, :name => '_')
-    assert_equal 30, query.available_filters.size
+    set_language_if_valid 'en'
+    query = IssueQuery.new
+    filter_count = query.available_filters.size
     fo = filters_options(query)
-    assert_equal 31, fo.size
+    assert_equal filter_count + 1, fo.size
     assert_equal [], fo[0]
-    assert_equal "status_id", fo[1][1]
-    assert_equal "project_id", fo[2][1]
-    assert_equal "tracker_id", fo[3][1]
-    assert_equal "priority_id", fo[4][1]
-    assert_equal "is_private", fo[17][1]
-    assert_equal "watcher_id", fo[18][1]
+
+    expected_order = [
+      "Status",
+      "Project",
+      "Tracker",
+      "Priority"
+    ]
+    assert_equal expected_order, (fo.map(&:first) & expected_order)
   end
 
   def test_filters_options_should_be_ordered_with_custom_fields
@@ -50,15 +52,18 @@ class QueriesHelperTest < ActionView::TestCase
               :name => 'order test', :field_format => 'string',
               :is_for_all => true, :is_filter => true
             )
-    User.current = User.find_by_login('admin')
-    query = IssueQuery.new(:project => nil, :name => '_')
-    assert_equal 32, query.available_filters.size
+    query = IssueQuery.new
+    filter_count = query.available_filters.size
     fo = filters_options(query)
-    assert_equal 33, fo.size
-    assert_equal "Searchable field", fo[19][0]
-    assert_equal "Database", fo[20][0]
-    assert_equal "Project's Development status", fo[21][0]
-    assert_equal "Author's order test", fo[22][0]
-    assert_equal "Assignee's order test", fo[23][0]
+    assert_equal filter_count + 1, fo.size
+
+    expected_order = [
+      "Searchable field",
+      "Database",
+      "Project's Development status",
+      "Author's order test",
+      "Assignee's order test"
+    ]
+    assert_equal expected_order, (fo.map(&:first) & expected_order)
   end
 end