@@ -0,0 +1,41 | |||||
|
1 | # Redmine - project management software | |||
|
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU General Public License | |||
|
15 | # along with this program; if not, write to the Free Software | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |||
|
19 | ||||
|
20 | class QueriesHelperTest < ActionView::TestCase | |||
|
21 | include QueriesHelper | |||
|
22 | ||||
|
23 | fixtures :projects, :enabled_modules, :users, :members, | |||
|
24 | :member_roles, :roles, :trackers, :issue_statuses, | |||
|
25 | :issue_categories, :enumerations, :issues, | |||
|
26 | :watchers, :custom_fields, :custom_values, :versions, | |||
|
27 | :queries, | |||
|
28 | :projects_trackers, | |||
|
29 | :custom_fields_trackers | |||
|
30 | ||||
|
31 | def test_order | |||
|
32 | User.current = User.find_by_login('admin') | |||
|
33 | query = Query.new(:project => nil, :name => '_') | |||
|
34 | assert_equal 30, query.available_filters.size | |||
|
35 | fo = filters_options(query) | |||
|
36 | assert_equal 31, fo.size | |||
|
37 | assert_equal [], fo[0] | |||
|
38 | assert_equal "tracker_id", fo[3][1] | |||
|
39 | assert_equal "priority_id", fo[4][1] | |||
|
40 | end | |||
|
41 | end |
@@ -19,11 +19,14 | |||||
19 |
|
19 | |||
20 | module QueriesHelper |
|
20 | module QueriesHelper | |
21 | def filters_options_for_select(query) |
|
21 | def filters_options_for_select(query) | |
|
22 | options_for_select(filters_options(query)) | |||
|
23 | end | |||
|
24 | ||||
|
25 | def filters_options(query) | |||
22 | options = [[]] |
|
26 | options = [[]] | |
23 | options += query.available_filters.sort {|a,b| a[1][:order] <=> b[1][:order]}.map do |field, field_options| |
|
27 | options += query.available_filters.sort {|a,b| a[1][:order] <=> b[1][:order]}.map do |field, field_options| | |
24 | [field_options[:name], field] |
|
28 | [field_options[:name], field] | |
25 | end |
|
29 | end | |
26 | options_for_select(options) |
|
|||
27 | end |
|
30 | end | |
28 |
|
31 | |||
29 | def column_header(column) |
|
32 | def column_header(column) |
General Comments 0
You need to be logged in to leave comments.
Login now