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