From: Jean-Philippe Lang Date: Sat, 16 Feb 2013 09:12:21 +0000 (+0000) Subject: Don't fail if new filter is added. X-Git-Tag: 2.3.0~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=723e21243e8df3cbb8937c32410797fa84c9cb79;p=redmine.git Don't fail if new filter is added. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11401 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/unit/helpers/queries_helper_test.rb b/test/unit/helpers/queries_helper_test.rb index 81604a38b..df6da519c 100644 --- a/test/unit/helpers/queries_helper_test.rb +++ b/test/unit/helpers/queries_helper_test.rb @@ -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