@@ -1,195 +1,194 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2013 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 IssuesHelperTest < ActionView::TestCase |
|
20 | class IssuesHelperTest < ActionView::TestCase | |
21 | include ApplicationHelper |
|
21 | include ApplicationHelper | |
22 | include IssuesHelper |
|
22 | include IssuesHelper | |
23 | include CustomFieldsHelper |
|
23 | include CustomFieldsHelper | |
24 | include ERB::Util |
|
24 | include ERB::Util | |
25 |
|
25 | |||
26 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
26 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
27 | :enumerations, :users, :issue_categories, |
|
27 | :enumerations, :users, :issue_categories, | |
28 | :projects_trackers, |
|
28 | :projects_trackers, | |
29 | :roles, |
|
29 | :roles, | |
30 | :member_roles, |
|
30 | :member_roles, | |
31 | :members, |
|
31 | :members, | |
32 | :enabled_modules, |
|
32 | :enabled_modules, | |
33 | :workflows, |
|
|||
34 | :custom_fields, |
|
33 | :custom_fields, | |
35 | :attachments, |
|
34 | :attachments, | |
36 | :versions |
|
35 | :versions | |
37 |
|
36 | |||
38 | def setup |
|
37 | def setup | |
39 | super |
|
38 | super | |
40 | set_language_if_valid('en') |
|
39 | set_language_if_valid('en') | |
41 | User.current = nil |
|
40 | User.current = nil | |
42 | end |
|
41 | end | |
43 |
|
42 | |||
44 | def test_issue_heading |
|
43 | def test_issue_heading | |
45 | assert_equal "Bug #1", issue_heading(Issue.find(1)) |
|
44 | assert_equal "Bug #1", issue_heading(Issue.find(1)) | |
46 | end |
|
45 | end | |
47 |
|
46 | |||
48 | def test_issues_destroy_confirmation_message_with_one_root_issue |
|
47 | def test_issues_destroy_confirmation_message_with_one_root_issue | |
49 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1)) |
|
48 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1)) | |
50 | end |
|
49 | end | |
51 |
|
50 | |||
52 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues |
|
51 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues | |
53 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
52 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) | |
54 | end |
|
53 | end | |
55 |
|
54 | |||
56 | def test_issues_destroy_confirmation_message_with_one_parent_issue |
|
55 | def test_issues_destroy_confirmation_message_with_one_parent_issue | |
57 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
56 | Issue.find(2).update_attribute :parent_issue_id, 1 | |
58 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1), |
|
57 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1), | |
59 | issues_destroy_confirmation_message(Issue.find(1)) |
|
58 | issues_destroy_confirmation_message(Issue.find(1)) | |
60 | end |
|
59 | end | |
61 |
|
60 | |||
62 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child |
|
61 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child | |
63 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
62 | Issue.find(2).update_attribute :parent_issue_id, 1 | |
64 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
63 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) | |
65 | end |
|
64 | end | |
66 |
|
65 | |||
67 | test 'IssuesHelper#show_detail with no_html should show a changing attribute' do |
|
66 | test 'IssuesHelper#show_detail with no_html should show a changing attribute' do | |
68 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') |
|
67 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
69 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) |
|
68 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) | |
70 | end |
|
69 | end | |
71 |
|
70 | |||
72 | test 'IssuesHelper#show_detail with no_html should show a new attribute' do |
|
71 | test 'IssuesHelper#show_detail with no_html should show a new attribute' do | |
73 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') |
|
72 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
74 | assert_equal "% Done set to 100", show_detail(detail, true) |
|
73 | assert_equal "% Done set to 100", show_detail(detail, true) | |
75 | end |
|
74 | end | |
76 |
|
75 | |||
77 | test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do |
|
76 | test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do | |
78 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') |
|
77 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
79 | assert_equal "% Done deleted (50)", show_detail(detail, true) |
|
78 | assert_equal "% Done deleted (50)", show_detail(detail, true) | |
80 | end |
|
79 | end | |
81 |
|
80 | |||
82 | test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do |
|
81 | test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do | |
83 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') |
|
82 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
84 | html = show_detail(detail, false) |
|
83 | html = show_detail(detail, false) | |
85 |
|
84 | |||
86 | assert_include '<strong>% Done</strong>', html |
|
85 | assert_include '<strong>% Done</strong>', html | |
87 | assert_include '<i>40</i>', html |
|
86 | assert_include '<i>40</i>', html | |
88 | assert_include '<i>100</i>', html |
|
87 | assert_include '<i>100</i>', html | |
89 | end |
|
88 | end | |
90 |
|
89 | |||
91 | test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do |
|
90 | test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do | |
92 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') |
|
91 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
93 | html = show_detail(detail, false) |
|
92 | html = show_detail(detail, false) | |
94 |
|
93 | |||
95 | assert_include '<strong>% Done</strong>', html |
|
94 | assert_include '<strong>% Done</strong>', html | |
96 | assert_include '<i>100</i>', html |
|
95 | assert_include '<i>100</i>', html | |
97 | end |
|
96 | end | |
98 |
|
97 | |||
99 | test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do |
|
98 | test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do | |
100 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') |
|
99 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
101 | html = show_detail(detail, false) |
|
100 | html = show_detail(detail, false) | |
102 |
|
101 | |||
103 | assert_include '<strong>% Done</strong>', html |
|
102 | assert_include '<strong>% Done</strong>', html | |
104 | assert_include '<del><i>50</i></del>', html |
|
103 | assert_include '<del><i>50</i></del>', html | |
105 | end |
|
104 | end | |
106 |
|
105 | |||
107 | test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do |
|
106 | test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do | |
108 | detail = JournalDetail.new( |
|
107 | detail = JournalDetail.new( | |
109 | :property => 'attr', |
|
108 | :property => 'attr', | |
110 | :old_value => '2010-01-01', |
|
109 | :old_value => '2010-01-01', | |
111 | :value => '2010-01-31', |
|
110 | :value => '2010-01-31', | |
112 | :prop_key => 'start_date' |
|
111 | :prop_key => 'start_date' | |
113 | ) |
|
112 | ) | |
114 | with_settings :date_format => '%m/%d/%Y' do |
|
113 | with_settings :date_format => '%m/%d/%Y' do | |
115 | assert_match "01/31/2010", show_detail(detail, true) |
|
114 | assert_match "01/31/2010", show_detail(detail, true) | |
116 | assert_match "01/01/2010", show_detail(detail, true) |
|
115 | assert_match "01/01/2010", show_detail(detail, true) | |
117 | end |
|
116 | end | |
118 | end |
|
117 | end | |
119 |
|
118 | |||
120 | test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do |
|
119 | test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do | |
121 | detail = JournalDetail.new( |
|
120 | detail = JournalDetail.new( | |
122 | :property => 'attr', |
|
121 | :property => 'attr', | |
123 | :old_value => '2010-01-01', |
|
122 | :old_value => '2010-01-01', | |
124 | :value => '2010-01-31', |
|
123 | :value => '2010-01-31', | |
125 | :prop_key => 'due_date' |
|
124 | :prop_key => 'due_date' | |
126 | ) |
|
125 | ) | |
127 | with_settings :date_format => '%m/%d/%Y' do |
|
126 | with_settings :date_format => '%m/%d/%Y' do | |
128 | assert_match "01/31/2010", show_detail(detail, true) |
|
127 | assert_match "01/31/2010", show_detail(detail, true) | |
129 | assert_match "01/01/2010", show_detail(detail, true) |
|
128 | assert_match "01/01/2010", show_detail(detail, true) | |
130 | end |
|
129 | end | |
131 | end |
|
130 | end | |
132 |
|
131 | |||
133 | test 'IssuesHelper#show_detail should show old and new values with a project attribute' do |
|
132 | test 'IssuesHelper#show_detail should show old and new values with a project attribute' do | |
134 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) |
|
133 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) | |
135 | assert_match 'eCookbook', show_detail(detail, true) |
|
134 | assert_match 'eCookbook', show_detail(detail, true) | |
136 | assert_match 'OnlineStore', show_detail(detail, true) |
|
135 | assert_match 'OnlineStore', show_detail(detail, true) | |
137 | end |
|
136 | end | |
138 |
|
137 | |||
139 | test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do |
|
138 | test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do | |
140 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) |
|
139 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) | |
141 | assert_match 'New', show_detail(detail, true) |
|
140 | assert_match 'New', show_detail(detail, true) | |
142 | assert_match 'Assigned', show_detail(detail, true) |
|
141 | assert_match 'Assigned', show_detail(detail, true) | |
143 | end |
|
142 | end | |
144 |
|
143 | |||
145 | test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do |
|
144 | test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do | |
146 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2) |
|
145 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2) | |
147 | assert_match 'Bug', show_detail(detail, true) |
|
146 | assert_match 'Bug', show_detail(detail, true) | |
148 | assert_match 'Feature request', show_detail(detail, true) |
|
147 | assert_match 'Feature request', show_detail(detail, true) | |
149 | end |
|
148 | end | |
150 |
|
149 | |||
151 | test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do |
|
150 | test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do | |
152 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2) |
|
151 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2) | |
153 | assert_match 'Redmine Admin', show_detail(detail, true) |
|
152 | assert_match 'Redmine Admin', show_detail(detail, true) | |
154 | assert_match 'John Smith', show_detail(detail, true) |
|
153 | assert_match 'John Smith', show_detail(detail, true) | |
155 | end |
|
154 | end | |
156 |
|
155 | |||
157 | test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do |
|
156 | test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do | |
158 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5) |
|
157 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5) | |
159 | assert_match 'Low', show_detail(detail, true) |
|
158 | assert_match 'Low', show_detail(detail, true) | |
160 | assert_match 'Normal', show_detail(detail, true) |
|
159 | assert_match 'Normal', show_detail(detail, true) | |
161 | end |
|
160 | end | |
162 |
|
161 | |||
163 | test 'IssuesHelper#show_detail should show old and new values with a category attribute' do |
|
162 | test 'IssuesHelper#show_detail should show old and new values with a category attribute' do | |
164 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2) |
|
163 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2) | |
165 | assert_match 'Printing', show_detail(detail, true) |
|
164 | assert_match 'Printing', show_detail(detail, true) | |
166 | assert_match 'Recipes', show_detail(detail, true) |
|
165 | assert_match 'Recipes', show_detail(detail, true) | |
167 | end |
|
166 | end | |
168 |
|
167 | |||
169 | test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do |
|
168 | test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do | |
170 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2) |
|
169 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2) | |
171 | assert_match '0.1', show_detail(detail, true) |
|
170 | assert_match '0.1', show_detail(detail, true) | |
172 | assert_match '1.0', show_detail(detail, true) |
|
171 | assert_match '1.0', show_detail(detail, true) | |
173 | end |
|
172 | end | |
174 |
|
173 | |||
175 | test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do |
|
174 | test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do | |
176 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3') |
|
175 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3') | |
177 | assert_match '5.00', show_detail(detail, true) |
|
176 | assert_match '5.00', show_detail(detail, true) | |
178 | assert_match '6.30', show_detail(detail, true) |
|
177 | assert_match '6.30', show_detail(detail, true) | |
179 | end |
|
178 | end | |
180 |
|
179 | |||
181 | test 'IssuesHelper#show_detail should show old and new values with a custom field' do |
|
180 | test 'IssuesHelper#show_detail should show old and new values with a custom field' do | |
182 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL') |
|
181 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL') | |
183 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) |
|
182 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) | |
184 | end |
|
183 | end | |
185 |
|
184 | |||
186 | test 'IssuesHelper#show_detail should show added file' do |
|
185 | test 'IssuesHelper#show_detail should show added file' do | |
187 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt') |
|
186 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt') | |
188 | assert_match 'error281.txt', show_detail(detail, true) |
|
187 | assert_match 'error281.txt', show_detail(detail, true) | |
189 | end |
|
188 | end | |
190 |
|
189 | |||
191 | test 'IssuesHelper#show_detail should show removed file' do |
|
190 | test 'IssuesHelper#show_detail should show removed file' do | |
192 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil) |
|
191 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil) | |
193 | assert_match 'error281.txt', show_detail(detail, true) |
|
192 | assert_match 'error281.txt', show_detail(detail, true) | |
194 | end |
|
193 | end | |
195 | end |
|
194 | end |
General Comments 0
You need to be logged in to leave comments.
Login now