##// END OF EJS Templates
Rewrites assertions....
Jean-Philippe Lang -
r13394:c32d75a697b3
parent child
Show More
@@ -1,96 +1,97
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2014 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_for_select_should_have_a_blank_option
33 33 options = filters_options_for_select(IssueQuery.new)
34 34 assert_select_in options, 'option[value=""]'
35 35 end
36 36
37 37 def test_filters_options_for_select_should_not_group_regular_filters
38 38 with_locale 'en' do
39 39 options = filters_options_for_select(IssueQuery.new)
40 assert_select_in options, 'option[value=status_id]:root'
40 assert_select_in options, 'optgroup option[value=status_id]', 0
41 41 assert_select_in options, 'option[value=status_id]', :text => 'Status'
42 42 end
43 43 end
44 44
45 45 def test_filters_options_for_select_should_group_date_filters
46 46 with_locale 'en' do
47 47 options = filters_options_for_select(IssueQuery.new)
48 48 assert_select_in options, 'optgroup[label=?]', 'Date', 1
49 49 assert_select_in options, 'optgroup > option[value=due_date]', :text => 'Due date'
50 50 end
51 51 end
52 52
53 53 def test_filters_options_for_select_should_not_group_only_one_date_filter
54 54 with_locale 'en' do
55 55 options = filters_options_for_select(TimeEntryQuery.new)
56 assert_select_in options, 'option[value=spent_on]'
56 57 assert_select_in options, 'optgroup[label=?]', 'Date', 0
57 assert_select_in options, 'option[value=spent_on]:root', :text => 'Date'
58 assert_select_in options, 'optgroup option[value=spent_on]', 0
58 59 end
59 60 end
60 61
61 62 def test_filters_options_for_select_should_group_relations_filters
62 63 with_locale 'en' do
63 64 options = filters_options_for_select(IssueQuery.new)
64 65 assert_select_in options, 'optgroup[label=?]', 'Related issues', 1
65 66 assert_select_in options, 'optgroup[label=?] > option', 'Related issues', 9
66 67 assert_select_in options, 'optgroup > option[value=relates]', :text => 'Related to'
67 68 end
68 69 end
69 70
70 71 def test_filters_options_for_select_should_group_associations_filters
71 72 CustomField.delete_all
72 73 cf1 = ProjectCustomField.create!(:name => 'Foo', :field_format => 'string', :is_filter => true)
73 74 cf2 = ProjectCustomField.create!(:name => 'Bar', :field_format => 'string', :is_filter => true)
74 75
75 76 with_locale 'en' do
76 77 options = filters_options_for_select(IssueQuery.new)
77 78 assert_select_in options, 'optgroup[label=?]', 'Project', 1
78 79 assert_select_in options, 'optgroup[label=?] > option', 'Project', 2
79 80 assert_select_in options, 'optgroup > option[value=?]', "project.cf_#{cf1.id}", :text => "Project's Foo"
80 81 end
81 82 end
82 83
83 84 def test_query_to_csv_should_translate_boolean_custom_field_values
84 85 f = IssueCustomField.generate!(:field_format => 'bool', :name => 'Boolean', :is_for_all => true, :trackers => Tracker.all)
85 86 issues = [
86 87 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '0'}),
87 88 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '1'})
88 89 ]
89 90
90 91 with_locale 'fr' do
91 92 csv = query_to_csv(issues, IssueQuery.new, :columns => 'all')
92 93 assert_include "Oui", csv
93 94 assert_include "Non", csv
94 95 end
95 96 end
96 97 end
General Comments 0
You need to be logged in to leave comments. Login now