##// END OF EJS Templates
Test failure (#24865)....
Jean-Philippe Lang -
r15840:1d9e6ebc38ff
parent child
Show More
@@ -1,97 +1,97
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../../test_helper', __FILE__)
18 require File.expand_path('../../../test_helper', __FILE__)
19
19
20 class QueriesHelperTest < Redmine::HelperTest
20 class QueriesHelperTest < Redmine::HelperTest
21 include QueriesHelper
21 include QueriesHelper
22 include Redmine::I18n
22 include Redmine::I18n
23
23
24 fixtures :projects, :enabled_modules, :users, :members,
24 fixtures :projects, :enabled_modules, :users, :members,
25 :member_roles, :roles, :trackers, :issue_statuses,
25 :member_roles, :roles, :trackers, :issue_statuses,
26 :issue_categories, :enumerations, :issues,
26 :issue_categories, :enumerations, :issues,
27 :watchers, :custom_fields, :custom_values, :versions,
27 :watchers, :custom_fields, :custom_values, :versions,
28 :queries,
28 :queries,
29 :projects_trackers,
29 :projects_trackers,
30 :custom_fields_trackers
30 :custom_fields_trackers
31
31
32 def test_filters_options_for_select_should_have_a_blank_option
32 def test_filters_options_for_select_should_have_a_blank_option
33 options = filters_options_for_select(IssueQuery.new)
33 options = filters_options_for_select(IssueQuery.new)
34 assert_select_in options, 'option[value=""]'
34 assert_select_in options, 'option[value=""]'
35 end
35 end
36
36
37 def test_filters_options_for_select_should_not_group_regular_filters
37 def test_filters_options_for_select_should_not_group_regular_filters
38 with_locale 'en' do
38 with_locale 'en' do
39 options = filters_options_for_select(IssueQuery.new)
39 options = filters_options_for_select(IssueQuery.new)
40 assert_select_in options, 'optgroup option[value=status_id]', 0
40 assert_select_in options, 'optgroup option[value=status_id]', 0
41 assert_select_in options, 'option[value=status_id]', :text => 'Status'
41 assert_select_in options, 'option[value=status_id]', :text => 'Status'
42 end
42 end
43 end
43 end
44
44
45 def test_filters_options_for_select_should_group_date_filters
45 def test_filters_options_for_select_should_group_date_filters
46 with_locale 'en' do
46 with_locale 'en' do
47 options = filters_options_for_select(IssueQuery.new)
47 options = filters_options_for_select(IssueQuery.new)
48 assert_select_in options, 'optgroup[label=?]', 'Date', 1
48 assert_select_in options, 'optgroup[label=?]', 'Date', 1
49 assert_select_in options, 'optgroup > option[value=due_date]', :text => 'Due date'
49 assert_select_in options, 'optgroup > option[value=due_date]', :text => 'Due date'
50 end
50 end
51 end
51 end
52
52
53 def test_filters_options_for_select_should_not_group_only_one_date_filter
53 def test_filters_options_for_select_should_not_group_only_one_date_filter
54 with_locale 'en' do
54 with_locale 'en' do
55 options = filters_options_for_select(TimeEntryQuery.new)
55 options = filters_options_for_select(TimeEntryQuery.new)
56 assert_select_in options, 'option[value=spent_on]'
56 assert_select_in options, 'option[value=spent_on]'
57 assert_select_in options, 'optgroup[label=?]', 'Date', 0
57 assert_select_in options, 'optgroup[label=?]', 'Date', 0
58 assert_select_in options, 'optgroup option[value=spent_on]', 0
58 assert_select_in options, 'optgroup option[value=spent_on]', 0
59 end
59 end
60 end
60 end
61
61
62 def test_filters_options_for_select_should_group_relations_filters
62 def test_filters_options_for_select_should_group_relations_filters
63 with_locale 'en' do
63 with_locale 'en' do
64 options = filters_options_for_select(IssueQuery.new)
64 options = filters_options_for_select(IssueQuery.new)
65 assert_select_in options, 'optgroup[label=?]', 'Relations', 1
65 assert_select_in options, 'optgroup[label=?]', 'Relations', 1
66 assert_select_in options, 'optgroup[label=?] > option', 'Relations', 11
66 assert_select_in options, 'optgroup[label=?] > option', 'Relations', 11
67 assert_select_in options, 'optgroup > option[value=relates]', :text => 'Related to'
67 assert_select_in options, 'optgroup > option[value=relates]', :text => 'Related to'
68 end
68 end
69 end
69 end
70
70
71 def test_filters_options_for_select_should_group_associations_filters
71 def test_filters_options_for_select_should_group_associations_filters
72 CustomField.delete_all
72 CustomField.delete_all
73 cf1 = ProjectCustomField.create!(:name => 'Foo', :field_format => 'string', :is_filter => true)
73 cf1 = ProjectCustomField.create!(:name => 'Foo', :field_format => 'string', :is_filter => true)
74 cf2 = ProjectCustomField.create!(:name => 'Bar', :field_format => 'string', :is_filter => true)
74 cf2 = ProjectCustomField.create!(:name => 'Bar', :field_format => 'string', :is_filter => true)
75
75
76 with_locale 'en' do
76 with_locale 'en' do
77 options = filters_options_for_select(IssueQuery.new)
77 options = filters_options_for_select(IssueQuery.new)
78 assert_select_in options, 'optgroup[label=?]', 'Project', 1
78 assert_select_in options, 'optgroup[label=?]', 'Project', 1
79 assert_select_in options, 'optgroup[label=?] > option', 'Project', 2
79 assert_select_in options, 'optgroup[label=?] > option', 'Project', 2
80 assert_select_in options, 'optgroup > option[value=?]', "project.cf_#{cf1.id}", :text => "Project's Foo"
80 assert_select_in options, 'optgroup > option[value=?]', "project.cf_#{cf1.id}", :text => "Project's Foo"
81 end
81 end
82 end
82 end
83
83
84 def test_query_to_csv_should_translate_boolean_custom_field_values
84 def test_query_to_csv_should_translate_boolean_custom_field_values
85 f = IssueCustomField.generate!(:field_format => 'bool', :name => 'Boolean', :is_for_all => true, :trackers => Tracker.all)
85 f = IssueCustomField.generate!(:field_format => 'bool', :name => 'Boolean', :is_for_all => true, :trackers => Tracker.all)
86 issues = [
86 issues = [
87 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '0'}),
87 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '0'}),
88 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '1'})
88 Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '1'})
89 ]
89 ]
90
90
91 with_locale 'fr' do
91 with_locale 'fr' do
92 csv = query_to_csv(issues, IssueQuery.new, :columns => 'all')
92 csv = query_to_csv(issues, IssueQuery.new(:column_names => ['id', "cf_#{f.id}"]))
93 assert_include "Oui", csv
93 assert_include "Oui", csv
94 assert_include "Non", csv
94 assert_include "Non", csv
95 end
95 end
96 end
96 end
97 end
97 end
General Comments 0
You need to be logged in to leave comments. Login now