@@ -1,64 +1,69 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class QueriesHelperTest < ActionView::TestCase |
|
21 | 21 | include QueriesHelper |
|
22 | 22 | include Redmine::I18n |
|
23 | 23 | |
|
24 | 24 | fixtures :projects, :enabled_modules, :users, :members, |
|
25 | 25 | :member_roles, :roles, :trackers, :issue_statuses, |
|
26 | 26 | :issue_categories, :enumerations, :issues, |
|
27 | 27 | :watchers, :custom_fields, :custom_values, :versions, |
|
28 | 28 | :queries, |
|
29 | 29 | :projects_trackers, |
|
30 | 30 | :custom_fields_trackers |
|
31 | 31 | |
|
32 | 32 | def test_filters_options_should_be_ordered |
|
33 | User.current = User.find_by_login('admin') | |
|
34 |
query = IssueQuery.new |
|
|
35 |
|
|
|
33 | set_language_if_valid 'en' | |
|
34 | query = IssueQuery.new | |
|
35 | filter_count = query.available_filters.size | |
|
36 | 36 | fo = filters_options(query) |
|
37 |
assert_equal |
|
|
37 | assert_equal filter_count + 1, fo.size | |
|
38 | 38 | assert_equal [], fo[0] |
|
39 | assert_equal "status_id", fo[1][1] | |
|
40 | assert_equal "project_id", fo[2][1] | |
|
41 | assert_equal "tracker_id", fo[3][1] | |
|
42 | assert_equal "priority_id", fo[4][1] | |
|
43 | assert_equal "is_private", fo[17][1] | |
|
44 | assert_equal "watcher_id", fo[18][1] | |
|
39 | ||
|
40 | expected_order = [ | |
|
41 | "Status", | |
|
42 | "Project", | |
|
43 | "Tracker", | |
|
44 | "Priority" | |
|
45 | ] | |
|
46 | assert_equal expected_order, (fo.map(&:first) & expected_order) | |
|
45 | 47 | end |
|
46 | 48 | |
|
47 | 49 | def test_filters_options_should_be_ordered_with_custom_fields |
|
48 | 50 | set_language_if_valid 'en' |
|
49 | 51 | field = UserCustomField.create!( |
|
50 | 52 | :name => 'order test', :field_format => 'string', |
|
51 | 53 | :is_for_all => true, :is_filter => true |
|
52 | 54 | ) |
|
53 | User.current = User.find_by_login('admin') | |
|
54 | query = IssueQuery.new(:project => nil, :name => '_') | |
|
55 | assert_equal 32, query.available_filters.size | |
|
55 | query = IssueQuery.new | |
|
56 | filter_count = query.available_filters.size | |
|
56 | 57 | fo = filters_options(query) |
|
57 |
assert_equal |
|
|
58 | assert_equal "Searchable field", fo[19][0] | |
|
59 | assert_equal "Database", fo[20][0] | |
|
60 | assert_equal "Project's Development status", fo[21][0] | |
|
61 | assert_equal "Author's order test", fo[22][0] | |
|
62 | assert_equal "Assignee's order test", fo[23][0] | |
|
58 | assert_equal filter_count + 1, fo.size | |
|
59 | ||
|
60 | expected_order = [ | |
|
61 | "Searchable field", | |
|
62 | "Database", | |
|
63 | "Project's Development status", | |
|
64 | "Author's order test", | |
|
65 | "Assignee's order test" | |
|
66 | ] | |
|
67 | assert_equal expected_order, (fo.map(&:first) & expected_order) | |
|
63 | 68 | end |
|
64 | 69 | end |
General Comments 0
You need to be logged in to leave comments.
Login now