@@ -1,271 +1,275 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2014 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 Redmine::I18n |
|
21 | include Redmine::I18n | |
22 | include IssuesHelper |
|
22 | include IssuesHelper | |
23 | include CustomFieldsHelper |
|
23 | include CustomFieldsHelper | |
24 | include ERB::Util |
|
24 | include ERB::Util | |
25 | include Rails.application.routes.url_helpers |
|
25 | include Rails.application.routes.url_helpers | |
26 |
|
26 | |||
27 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
27 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
28 | :enumerations, :users, :issue_categories, |
|
28 | :enumerations, :users, :issue_categories, | |
29 | :projects_trackers, |
|
29 | :projects_trackers, | |
30 | :roles, |
|
30 | :roles, | |
31 | :member_roles, |
|
31 | :member_roles, | |
32 | :members, |
|
32 | :members, | |
33 | :enabled_modules, |
|
33 | :enabled_modules, | |
34 | :custom_fields, |
|
34 | :custom_fields, | |
35 | :attachments, |
|
35 | :attachments, | |
36 | :versions |
|
36 | :versions | |
37 |
|
37 | |||
38 | def setup |
|
38 | def setup | |
39 | super |
|
39 | super | |
40 | set_language_if_valid('en') |
|
40 | set_language_if_valid('en') | |
41 | User.current = nil |
|
41 | User.current = nil | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def test_issue_heading |
|
44 | def test_issue_heading | |
45 | assert_equal "Bug #1", issue_heading(Issue.find(1)) |
|
45 | assert_equal "Bug #1", issue_heading(Issue.find(1)) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def test_issues_destroy_confirmation_message_with_one_root_issue |
|
48 | def test_issues_destroy_confirmation_message_with_one_root_issue | |
49 | assert_equal l(:text_issues_destroy_confirmation), |
|
49 | assert_equal l(:text_issues_destroy_confirmation), | |
50 | issues_destroy_confirmation_message(Issue.find(1)) |
|
50 | issues_destroy_confirmation_message(Issue.find(1)) | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues |
|
53 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues | |
54 | assert_equal l(:text_issues_destroy_confirmation), |
|
54 | assert_equal l(:text_issues_destroy_confirmation), | |
55 | issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
55 | issues_destroy_confirmation_message(Issue.find([1, 2])) | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def test_issues_destroy_confirmation_message_with_one_parent_issue |
|
58 | def test_issues_destroy_confirmation_message_with_one_parent_issue | |
59 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
59 | Issue.find(2).update_attribute :parent_issue_id, 1 | |
60 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + |
|
60 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + | |
61 | l(:text_issues_destroy_descendants_confirmation, :count => 1), |
|
61 | l(:text_issues_destroy_descendants_confirmation, :count => 1), | |
62 | issues_destroy_confirmation_message(Issue.find(1)) |
|
62 | issues_destroy_confirmation_message(Issue.find(1)) | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child |
|
65 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child | |
66 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
66 | Issue.find(2).update_attribute :parent_issue_id, 1 | |
67 | assert_equal l(:text_issues_destroy_confirmation), |
|
67 | assert_equal l(:text_issues_destroy_confirmation), | |
68 | issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
68 | issues_destroy_confirmation_message(Issue.find([1, 2])) | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | test 'show_detail with no_html should show a changing attribute' do |
|
71 | test 'show_detail with no_html should show a changing attribute' do | |
72 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', |
|
72 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', | |
73 | :value => '100', :prop_key => 'done_ratio') |
|
73 | :value => '100', :prop_key => 'done_ratio') | |
74 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) |
|
74 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | test 'show_detail with no_html should show a new attribute' do |
|
77 | test 'show_detail with no_html should show a new attribute' do | |
78 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, |
|
78 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, | |
79 | :value => '100', :prop_key => 'done_ratio') |
|
79 | :value => '100', :prop_key => 'done_ratio') | |
80 | assert_equal "% Done set to 100", show_detail(detail, true) |
|
80 | assert_equal "% Done set to 100", show_detail(detail, true) | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | test 'show_detail with no_html should show a deleted attribute' do |
|
83 | test 'show_detail with no_html should show a deleted attribute' do | |
84 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', |
|
84 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', | |
85 | :value => nil, :prop_key => 'done_ratio') |
|
85 | :value => nil, :prop_key => 'done_ratio') | |
86 | assert_equal "% Done deleted (50)", show_detail(detail, true) |
|
86 | assert_equal "% Done deleted (50)", show_detail(detail, true) | |
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | test 'show_detail with html should show a changing attribute with HTML highlights' do |
|
89 | test 'show_detail with html should show a changing attribute with HTML highlights' do | |
90 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', |
|
90 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', | |
91 | :value => '100', :prop_key => 'done_ratio') |
|
91 | :value => '100', :prop_key => 'done_ratio') | |
92 | html = show_detail(detail, false) |
|
92 | html = show_detail(detail, false) | |
93 | assert_include '<strong>% Done</strong>', html |
|
93 | assert_include '<strong>% Done</strong>', html | |
94 | assert_include '<i>40</i>', html |
|
94 | assert_include '<i>40</i>', html | |
95 | assert_include '<i>100</i>', html |
|
95 | assert_include '<i>100</i>', html | |
96 | end |
|
96 | end | |
97 |
|
97 | |||
98 | test 'show_detail with html should show a new attribute with HTML highlights' do |
|
98 | test 'show_detail with html should show a new attribute with HTML highlights' do | |
99 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, |
|
99 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, | |
100 | :value => '100', :prop_key => 'done_ratio') |
|
100 | :value => '100', :prop_key => 'done_ratio') | |
101 | html = show_detail(detail, false) |
|
101 | html = show_detail(detail, false) | |
102 | assert_include '<strong>% Done</strong>', html |
|
102 | assert_include '<strong>% Done</strong>', html | |
103 | assert_include '<i>100</i>', html |
|
103 | assert_include '<i>100</i>', html | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | test 'show_detail with html should show a deleted attribute with HTML highlights' do |
|
106 | test 'show_detail with html should show a deleted attribute with HTML highlights' do | |
107 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', |
|
107 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', | |
108 | :value => nil, :prop_key => 'done_ratio') |
|
108 | :value => nil, :prop_key => 'done_ratio') | |
109 | html = show_detail(detail, false) |
|
109 | html = show_detail(detail, false) | |
110 | assert_include '<strong>% Done</strong>', html |
|
110 | assert_include '<strong>% Done</strong>', html | |
111 | assert_include '<del><i>50</i></del>', html |
|
111 | assert_include '<del><i>50</i></del>', html | |
112 | end |
|
112 | end | |
113 |
|
113 | |||
114 | test 'show_detail with a start_date attribute should format the dates' do |
|
114 | test 'show_detail with a start_date attribute should format the dates' do | |
115 | detail = JournalDetail.new( |
|
115 | detail = JournalDetail.new( | |
116 | :property => 'attr', |
|
116 | :property => 'attr', | |
117 | :old_value => '2010-01-01', |
|
117 | :old_value => '2010-01-01', | |
118 | :value => '2010-01-31', |
|
118 | :value => '2010-01-31', | |
119 | :prop_key => 'start_date' |
|
119 | :prop_key => 'start_date' | |
120 | ) |
|
120 | ) | |
121 | with_settings :date_format => '%m/%d/%Y' do |
|
121 | with_settings :date_format => '%m/%d/%Y' do | |
122 | assert_match "01/31/2010", show_detail(detail, true) |
|
122 | assert_match "01/31/2010", show_detail(detail, true) | |
123 | assert_match "01/01/2010", show_detail(detail, true) |
|
123 | assert_match "01/01/2010", show_detail(detail, true) | |
124 | end |
|
124 | end | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
127 | test 'show_detail with a due_date attribute should format the dates' do |
|
127 | test 'show_detail with a due_date attribute should format the dates' do | |
128 | detail = JournalDetail.new( |
|
128 | detail = JournalDetail.new( | |
129 | :property => 'attr', |
|
129 | :property => 'attr', | |
130 | :old_value => '2010-01-01', |
|
130 | :old_value => '2010-01-01', | |
131 | :value => '2010-01-31', |
|
131 | :value => '2010-01-31', | |
132 | :prop_key => 'due_date' |
|
132 | :prop_key => 'due_date' | |
133 | ) |
|
133 | ) | |
134 | with_settings :date_format => '%m/%d/%Y' do |
|
134 | with_settings :date_format => '%m/%d/%Y' do | |
135 | assert_match "01/31/2010", show_detail(detail, true) |
|
135 | assert_match "01/31/2010", show_detail(detail, true) | |
136 | assert_match "01/01/2010", show_detail(detail, true) |
|
136 | assert_match "01/01/2010", show_detail(detail, true) | |
137 | end |
|
137 | end | |
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | test 'show_detail should show old and new values with a project attribute' do |
|
140 | test 'show_detail should show old and new values with a project attribute' do | |
141 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', |
|
141 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', | |
142 | :old_value => 1, :value => 2) |
|
142 | :old_value => 1, :value => 2) | |
143 | assert_match 'eCookbook', show_detail(detail, true) |
|
143 | assert_match 'eCookbook', show_detail(detail, true) | |
144 | assert_match 'OnlineStore', show_detail(detail, true) |
|
144 | assert_match 'OnlineStore', show_detail(detail, true) | |
145 | end |
|
145 | end | |
146 |
|
146 | |||
147 | test 'show_detail should show old and new values with a issue status attribute' do |
|
147 | test 'show_detail should show old and new values with a issue status attribute' do | |
148 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', |
|
148 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', | |
149 | :old_value => 1, :value => 2) |
|
149 | :old_value => 1, :value => 2) | |
150 | assert_match 'New', show_detail(detail, true) |
|
150 | assert_match 'New', show_detail(detail, true) | |
151 | assert_match 'Assigned', show_detail(detail, true) |
|
151 | assert_match 'Assigned', show_detail(detail, true) | |
152 | end |
|
152 | end | |
153 |
|
153 | |||
154 | test 'show_detail should show old and new values with a tracker attribute' do |
|
154 | test 'show_detail should show old and new values with a tracker attribute' do | |
155 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', |
|
155 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', | |
156 | :old_value => 1, :value => 2) |
|
156 | :old_value => 1, :value => 2) | |
157 | assert_match 'Bug', show_detail(detail, true) |
|
157 | assert_match 'Bug', show_detail(detail, true) | |
158 | assert_match 'Feature request', show_detail(detail, true) |
|
158 | assert_match 'Feature request', show_detail(detail, true) | |
159 | end |
|
159 | end | |
160 |
|
160 | |||
161 | test 'show_detail should show old and new values with a assigned to attribute' do |
|
161 | test 'show_detail should show old and new values with a assigned to attribute' do | |
162 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', |
|
162 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', | |
163 | :old_value => 1, :value => 2) |
|
163 | :old_value => 1, :value => 2) | |
164 | assert_match 'Redmine Admin', show_detail(detail, true) |
|
164 | assert_match 'Redmine Admin', show_detail(detail, true) | |
165 | assert_match 'John Smith', show_detail(detail, true) |
|
165 | assert_match 'John Smith', show_detail(detail, true) | |
166 | end |
|
166 | end | |
167 |
|
167 | |||
168 | test 'show_detail should show old and new values with a priority attribute' do |
|
168 | test 'show_detail should show old and new values with a priority attribute' do | |
169 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', |
|
169 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', | |
170 | :old_value => 4, :value => 5) |
|
170 | :old_value => 4, :value => 5) | |
171 | assert_match 'Low', show_detail(detail, true) |
|
171 | assert_match 'Low', show_detail(detail, true) | |
172 | assert_match 'Normal', show_detail(detail, true) |
|
172 | assert_match 'Normal', show_detail(detail, true) | |
173 | end |
|
173 | end | |
174 |
|
174 | |||
175 | test 'show_detail should show old and new values with a category attribute' do |
|
175 | test 'show_detail should show old and new values with a category attribute' do | |
176 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', |
|
176 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', | |
177 | :old_value => 1, :value => 2) |
|
177 | :old_value => 1, :value => 2) | |
178 | assert_match 'Printing', show_detail(detail, true) |
|
178 | assert_match 'Printing', show_detail(detail, true) | |
179 | assert_match 'Recipes', show_detail(detail, true) |
|
179 | assert_match 'Recipes', show_detail(detail, true) | |
180 | end |
|
180 | end | |
181 |
|
181 | |||
182 | test 'show_detail should show old and new values with a fixed version attribute' do |
|
182 | test 'show_detail should show old and new values with a fixed version attribute' do | |
183 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', |
|
183 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', | |
184 | :old_value => 1, :value => 2) |
|
184 | :old_value => 1, :value => 2) | |
185 | assert_match '0.1', show_detail(detail, true) |
|
185 | assert_match '0.1', show_detail(detail, true) | |
186 | assert_match '1.0', show_detail(detail, true) |
|
186 | assert_match '1.0', show_detail(detail, true) | |
187 | end |
|
187 | end | |
188 |
|
188 | |||
189 | test 'show_detail should show old and new values with a estimated hours attribute' do |
|
189 | test 'show_detail should show old and new values with a estimated hours attribute' do | |
190 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', |
|
190 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', | |
191 | :old_value => '5', :value => '6.3') |
|
191 | :old_value => '5', :value => '6.3') | |
192 | assert_match '5.00', show_detail(detail, true) |
|
192 | assert_match '5.00', show_detail(detail, true) | |
193 | assert_match '6.30', show_detail(detail, true) |
|
193 | assert_match '6.30', show_detail(detail, true) | |
194 | end |
|
194 | end | |
195 |
|
195 | |||
196 | test 'show_detail should show old and new values with a custom field' do |
|
196 | test 'show_detail should show old and new values with a custom field' do | |
197 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', |
|
197 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', | |
198 | :old_value => 'MySQL', :value => 'PostgreSQL') |
|
198 | :old_value => 'MySQL', :value => 'PostgreSQL') | |
199 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) |
|
199 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) | |
200 | end |
|
200 | end | |
201 |
|
201 | |||
202 | test 'show_detail should show added file' do |
|
202 | test 'show_detail should show added file' do | |
203 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', |
|
203 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', | |
204 | :old_value => nil, :value => 'error281.txt') |
|
204 | :old_value => nil, :value => 'error281.txt') | |
205 | assert_match 'error281.txt', show_detail(detail, true) |
|
205 | assert_match 'error281.txt', show_detail(detail, true) | |
206 | end |
|
206 | end | |
207 |
|
207 | |||
208 | test 'show_detail should show removed file' do |
|
208 | test 'show_detail should show removed file' do | |
209 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', |
|
209 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', | |
210 | :old_value => 'error281.txt', :value => nil) |
|
210 | :old_value => 'error281.txt', :value => nil) | |
211 | assert_match 'error281.txt', show_detail(detail, true) |
|
211 | assert_match 'error281.txt', show_detail(detail, true) | |
212 | end |
|
212 | end | |
213 |
|
213 | |||
214 | def test_show_detail_relation_added |
|
214 | def test_show_detail_relation_added | |
215 | detail = JournalDetail.new(:property => 'relation', |
|
215 | detail = JournalDetail.new(:property => 'relation', | |
216 | :prop_key => 'precedes', |
|
216 | :prop_key => 'precedes', | |
217 | :value => 1) |
|
217 | :value => 1) | |
218 | assert_equal "Precedes Bug #1: Can't print recipes added", show_detail(detail, true) |
|
218 | assert_equal "Precedes Bug #1: Can't print recipes added", show_detail(detail, true) | |
219 | assert_match %r{<strong>Precedes</strong> <i><a href="/issues/1" class=".+">Bug #1</a>: #{ESCAPED_UCANT} print recipes</i> added}, |
|
219 | str = link_to("Bug #1", "/issues/1", :class => Issue.find(1).css_classes) | |
220 | show_detail(detail, false) |
|
220 | assert_equal "<strong>Precedes</strong> <i>#{str}: #{ESCAPED_UCANT} print recipes</i> added", | |
|
221 | show_detail(detail, false) | |||
221 | end |
|
222 | end | |
222 |
|
223 | |||
223 | def test_show_detail_relation_added_with_inexistant_issue |
|
224 | def test_show_detail_relation_added_with_inexistant_issue | |
224 | inexistant_issue_number = 9999 |
|
225 | inexistant_issue_number = 9999 | |
225 | assert_nil Issue.find_by_id(inexistant_issue_number) |
|
226 | assert_nil Issue.find_by_id(inexistant_issue_number) | |
226 | detail = JournalDetail.new(:property => 'relation', |
|
227 | detail = JournalDetail.new(:property => 'relation', | |
227 | :prop_key => 'precedes', |
|
228 | :prop_key => 'precedes', | |
228 | :value => inexistant_issue_number) |
|
229 | :value => inexistant_issue_number) | |
229 | assert_equal "Precedes Issue ##{inexistant_issue_number} added", show_detail(detail, true) |
|
230 | assert_equal "Precedes Issue ##{inexistant_issue_number} added", show_detail(detail, true) | |
230 | assert_equal "<strong>Precedes</strong> <i>Issue ##{inexistant_issue_number}</i> added", show_detail(detail, false) |
|
231 | assert_equal "<strong>Precedes</strong> <i>Issue ##{inexistant_issue_number}</i> added", show_detail(detail, false) | |
231 | end |
|
232 | end | |
232 |
|
233 | |||
233 | def test_show_detail_relation_added_should_not_disclose_issue_that_is_not_visible |
|
234 | def test_show_detail_relation_added_should_not_disclose_issue_that_is_not_visible | |
234 | issue = Issue.generate!(:is_private => true) |
|
235 | issue = Issue.generate!(:is_private => true) | |
235 | detail = JournalDetail.new(:property => 'relation', |
|
236 | detail = JournalDetail.new(:property => 'relation', | |
236 | :prop_key => 'precedes', |
|
237 | :prop_key => 'precedes', | |
237 | :value => issue.id) |
|
238 | :value => issue.id) | |
238 |
|
239 | |||
239 | assert_equal "Precedes Issue ##{issue.id} added", show_detail(detail, true) |
|
240 | assert_equal "Precedes Issue ##{issue.id} added", show_detail(detail, true) | |
240 | assert_equal "<strong>Precedes</strong> <i>Issue ##{issue.id}</i> added", show_detail(detail, false) |
|
241 | assert_equal "<strong>Precedes</strong> <i>Issue ##{issue.id}</i> added", show_detail(detail, false) | |
241 | end |
|
242 | end | |
242 |
|
243 | |||
243 | def test_show_detail_relation_deleted |
|
244 | def test_show_detail_relation_deleted | |
244 | detail = JournalDetail.new(:property => 'relation', |
|
245 | detail = JournalDetail.new(:property => 'relation', | |
245 | :prop_key => 'precedes', |
|
246 | :prop_key => 'precedes', | |
246 | :old_value => 1) |
|
247 | :old_value => 1) | |
247 | assert_equal "Precedes deleted (Bug #1: Can't print recipes)", show_detail(detail, true) |
|
248 | assert_equal "Precedes deleted (Bug #1: Can't print recipes)", show_detail(detail, true) | |
248 | assert_match %r{<strong>Precedes</strong> deleted \(<i><a href="/issues/1" class=".+">Bug #1</a>: #{ESCAPED_UCANT} print recipes</i>\)}, |
|
249 | str = link_to("Bug #1", | |
|
250 | "/issues/1", | |||
|
251 | :class => Issue.find(1).css_classes) | |||
|
252 | assert_equal "<strong>Precedes</strong> deleted (<i>#{str}: #{ESCAPED_UCANT} print recipes</i>)", | |||
249 | show_detail(detail, false) |
|
253 | show_detail(detail, false) | |
250 | end |
|
254 | end | |
251 |
|
255 | |||
252 | def test_show_detail_relation_deleted_with_inexistant_issue |
|
256 | def test_show_detail_relation_deleted_with_inexistant_issue | |
253 | inexistant_issue_number = 9999 |
|
257 | inexistant_issue_number = 9999 | |
254 | assert_nil Issue.find_by_id(inexistant_issue_number) |
|
258 | assert_nil Issue.find_by_id(inexistant_issue_number) | |
255 | detail = JournalDetail.new(:property => 'relation', |
|
259 | detail = JournalDetail.new(:property => 'relation', | |
256 | :prop_key => 'precedes', |
|
260 | :prop_key => 'precedes', | |
257 | :old_value => inexistant_issue_number) |
|
261 | :old_value => inexistant_issue_number) | |
258 | assert_equal "Precedes deleted (Issue #9999)", show_detail(detail, true) |
|
262 | assert_equal "Precedes deleted (Issue #9999)", show_detail(detail, true) | |
259 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue #9999</i>)", show_detail(detail, false) |
|
263 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue #9999</i>)", show_detail(detail, false) | |
260 | end |
|
264 | end | |
261 |
|
265 | |||
262 | def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visible |
|
266 | def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visible | |
263 | issue = Issue.generate!(:is_private => true) |
|
267 | issue = Issue.generate!(:is_private => true) | |
264 | detail = JournalDetail.new(:property => 'relation', |
|
268 | detail = JournalDetail.new(:property => 'relation', | |
265 | :prop_key => 'precedes', |
|
269 | :prop_key => 'precedes', | |
266 | :old_value => issue.id) |
|
270 | :old_value => issue.id) | |
267 |
|
271 | |||
268 | assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true) |
|
272 | assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true) | |
269 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false) |
|
273 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false) | |
270 | end |
|
274 | end | |
271 | end |
|
275 | end |
General Comments 0
You need to be logged in to leave comments.
Login now