@@ -1,890 +1,890 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2016 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 MailerTest < ActiveSupport::TestCase |
|
21 | 21 | include Redmine::I18n |
|
22 | 22 | include Rails::Dom::Testing::Assertions |
|
23 | fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :members, | |
|
23 | fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :user_preferences, :members, | |
|
24 | 24 | :member_roles, :roles, :documents, :attachments, :news, |
|
25 | 25 | :tokens, :journals, :journal_details, :changesets, |
|
26 | 26 | :trackers, :projects_trackers, |
|
27 | 27 | :issue_statuses, :enumerations, :messages, :boards, :repositories, |
|
28 | 28 | :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, |
|
29 | 29 | :versions, |
|
30 | 30 | :comments |
|
31 | 31 | |
|
32 | 32 | def setup |
|
33 | 33 | ActionMailer::Base.deliveries.clear |
|
34 | 34 | Setting.plain_text_mail = '0' |
|
35 | 35 | Setting.default_language = 'en' |
|
36 | 36 | User.current = nil |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def test_generated_links_in_emails |
|
40 | 40 | with_settings :host_name => 'mydomain.foo', :protocol => 'https' do |
|
41 | 41 | journal = Journal.find(3) |
|
42 | 42 | assert Mailer.deliver_issue_edit(journal) |
|
43 | 43 | end |
|
44 | 44 | mail = last_email |
|
45 | 45 | assert_not_nil mail |
|
46 | 46 | |
|
47 | 47 | assert_select_email do |
|
48 | 48 | # link to the main ticket |
|
49 | 49 | assert_select 'a[href=?]', |
|
50 | 50 | 'https://mydomain.foo/issues/2#change-3', |
|
51 | 51 | :text => 'Feature request #2: Add ingredients categories' |
|
52 | 52 | # link to a referenced ticket |
|
53 | 53 | assert_select 'a[href=?][title=?]', |
|
54 | 54 | 'https://mydomain.foo/issues/1', |
|
55 | 55 | "Bug: Cannot print recipes (New)", |
|
56 | 56 | :text => '#1' |
|
57 | 57 | # link to a changeset |
|
58 | 58 | assert_select 'a[href=?][title=?]', |
|
59 | 59 | 'https://mydomain.foo/projects/ecookbook/repository/revisions/2', |
|
60 | 60 | 'This commit fixes #1, #2 and references #1 & #3', |
|
61 | 61 | :text => 'r2' |
|
62 | 62 | # link to a description diff |
|
63 | 63 | assert_select 'a[href^=?][title=?]', |
|
64 | 64 | # should be https://mydomain.foo/journals/diff/3?detail_id=4 |
|
65 | 65 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
66 | 66 | # attribute value |
|
67 | 67 | 'https://mydomain.foo/journals/3/diff', |
|
68 | 68 | 'View differences', |
|
69 | 69 | :text => 'diff' |
|
70 | 70 | # link to an attachment |
|
71 | 71 | assert_select 'a[href=?]', |
|
72 | 72 | 'https://mydomain.foo/attachments/download/4/source.rb', |
|
73 | 73 | :text => 'source.rb' |
|
74 | 74 | end |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | def test_generated_links_with_prefix |
|
78 | 78 | relative_url_root = Redmine::Utils.relative_url_root |
|
79 | 79 | with_settings :host_name => 'mydomain.foo/rdm', :protocol => 'http' do |
|
80 | 80 | journal = Journal.find(3) |
|
81 | 81 | assert Mailer.deliver_issue_edit(journal) |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | mail = last_email |
|
85 | 85 | assert_not_nil mail |
|
86 | 86 | |
|
87 | 87 | assert_select_email do |
|
88 | 88 | # link to the main ticket |
|
89 | 89 | assert_select 'a[href=?]', |
|
90 | 90 | 'http://mydomain.foo/rdm/issues/2#change-3', |
|
91 | 91 | :text => 'Feature request #2: Add ingredients categories' |
|
92 | 92 | # link to a referenced ticket |
|
93 | 93 | assert_select 'a[href=?][title=?]', |
|
94 | 94 | 'http://mydomain.foo/rdm/issues/1', |
|
95 | 95 | "Bug: Cannot print recipes (New)", |
|
96 | 96 | :text => '#1' |
|
97 | 97 | # link to a changeset |
|
98 | 98 | assert_select 'a[href=?][title=?]', |
|
99 | 99 | 'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2', |
|
100 | 100 | 'This commit fixes #1, #2 and references #1 & #3', |
|
101 | 101 | :text => 'r2' |
|
102 | 102 | # link to a description diff |
|
103 | 103 | assert_select 'a[href^=?][title=?]', |
|
104 | 104 | # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 |
|
105 | 105 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
106 | 106 | # attribute value |
|
107 | 107 | 'http://mydomain.foo/rdm/journals/3/diff', |
|
108 | 108 | 'View differences', |
|
109 | 109 | :text => 'diff' |
|
110 | 110 | # link to an attachment |
|
111 | 111 | assert_select 'a[href=?]', |
|
112 | 112 | 'http://mydomain.foo/rdm/attachments/download/4/source.rb', |
|
113 | 113 | :text => 'source.rb' |
|
114 | 114 | end |
|
115 | 115 | end |
|
116 | 116 | |
|
117 | 117 | def test_generated_links_with_port_and_prefix |
|
118 | 118 | with_settings :host_name => '10.0.0.1:81/redmine', :protocol => 'http' do |
|
119 | 119 | Mailer.test_email(User.find(1)).deliver |
|
120 | 120 | mail = last_email |
|
121 | 121 | assert_not_nil mail |
|
122 | 122 | assert_include 'http://10.0.0.1:81/redmine', mail_body(mail) |
|
123 | 123 | end |
|
124 | 124 | end |
|
125 | 125 | |
|
126 | 126 | def test_generated_links_with_port |
|
127 | 127 | with_settings :host_name => '10.0.0.1:81', :protocol => 'http' do |
|
128 | 128 | Mailer.test_email(User.find(1)).deliver |
|
129 | 129 | mail = last_email |
|
130 | 130 | assert_not_nil mail |
|
131 | 131 | assert_include 'http://10.0.0.1:81', mail_body(mail) |
|
132 | 132 | end |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | def test_issue_edit_should_generate_url_with_hostname_for_relations |
|
136 | 136 | journal = Journal.new(:journalized => Issue.find(1), :user => User.find(1), :created_on => Time.now) |
|
137 | 137 | journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'label_relates_to', :value => 2) |
|
138 | 138 | Mailer.deliver_issue_edit(journal) |
|
139 | 139 | assert_not_nil last_email |
|
140 | 140 | assert_select_email do |
|
141 | 141 | assert_select 'a[href=?]', 'http://localhost:3000/issues/2', :text => 'Feature request #2' |
|
142 | 142 | end |
|
143 | 143 | end |
|
144 | 144 | |
|
145 | 145 | def test_generated_links_with_prefix_and_no_relative_url_root |
|
146 | 146 | relative_url_root = Redmine::Utils.relative_url_root |
|
147 | 147 | Redmine::Utils.relative_url_root = nil |
|
148 | 148 | |
|
149 | 149 | with_settings :host_name => 'mydomain.foo/rdm', :protocol => 'http' do |
|
150 | 150 | journal = Journal.find(3) |
|
151 | 151 | assert Mailer.deliver_issue_edit(journal) |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | mail = last_email |
|
155 | 155 | assert_not_nil mail |
|
156 | 156 | |
|
157 | 157 | assert_select_email do |
|
158 | 158 | # link to the main ticket |
|
159 | 159 | assert_select 'a[href=?]', |
|
160 | 160 | 'http://mydomain.foo/rdm/issues/2#change-3', |
|
161 | 161 | :text => 'Feature request #2: Add ingredients categories' |
|
162 | 162 | # link to a referenced ticket |
|
163 | 163 | assert_select 'a[href=?][title=?]', |
|
164 | 164 | 'http://mydomain.foo/rdm/issues/1', |
|
165 | 165 | "Bug: Cannot print recipes (New)", |
|
166 | 166 | :text => '#1' |
|
167 | 167 | # link to a changeset |
|
168 | 168 | assert_select 'a[href=?][title=?]', |
|
169 | 169 | 'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2', |
|
170 | 170 | 'This commit fixes #1, #2 and references #1 & #3', |
|
171 | 171 | :text => 'r2' |
|
172 | 172 | # link to a description diff |
|
173 | 173 | assert_select 'a[href^=?][title=?]', |
|
174 | 174 | # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 |
|
175 | 175 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
176 | 176 | # attribute value |
|
177 | 177 | 'http://mydomain.foo/rdm/journals/3/diff', |
|
178 | 178 | 'View differences', |
|
179 | 179 | :text => 'diff' |
|
180 | 180 | # link to an attachment |
|
181 | 181 | assert_select 'a[href=?]', |
|
182 | 182 | 'http://mydomain.foo/rdm/attachments/download/4/source.rb', |
|
183 | 183 | :text => 'source.rb' |
|
184 | 184 | end |
|
185 | 185 | ensure |
|
186 | 186 | # restore it |
|
187 | 187 | Redmine::Utils.relative_url_root = relative_url_root |
|
188 | 188 | end |
|
189 | 189 | |
|
190 | 190 | def test_email_headers |
|
191 | 191 | issue = Issue.find(1) |
|
192 | 192 | Mailer.deliver_issue_add(issue) |
|
193 | 193 | mail = last_email |
|
194 | 194 | assert_not_nil mail |
|
195 | 195 | assert_equal 'All', mail.header['X-Auto-Response-Suppress'].to_s |
|
196 | 196 | assert_equal 'auto-generated', mail.header['Auto-Submitted'].to_s |
|
197 | 197 | assert_equal '<redmine.example.net>', mail.header['List-Id'].to_s |
|
198 | 198 | end |
|
199 | 199 | |
|
200 | 200 | def test_email_headers_should_include_sender |
|
201 | 201 | issue = Issue.find(1) |
|
202 | 202 | Mailer.deliver_issue_add(issue) |
|
203 | 203 | mail = last_email |
|
204 | 204 | assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s |
|
205 | 205 | end |
|
206 | 206 | |
|
207 | 207 | def test_plain_text_mail |
|
208 | 208 | Setting.plain_text_mail = 1 |
|
209 | 209 | journal = Journal.find(2) |
|
210 | 210 | Mailer.deliver_issue_edit(journal) |
|
211 | 211 | mail = last_email |
|
212 | 212 | assert_equal "text/plain; charset=UTF-8", mail.content_type |
|
213 | 213 | assert_equal 0, mail.parts.size |
|
214 | 214 | assert !mail.encoded.include?('href') |
|
215 | 215 | end |
|
216 | 216 | |
|
217 | 217 | def test_html_mail |
|
218 | 218 | Setting.plain_text_mail = 0 |
|
219 | 219 | journal = Journal.find(2) |
|
220 | 220 | Mailer.deliver_issue_edit(journal) |
|
221 | 221 | mail = last_email |
|
222 | 222 | assert_equal 2, mail.parts.size |
|
223 | 223 | assert mail.encoded.include?('href') |
|
224 | 224 | end |
|
225 | 225 | |
|
226 | 226 | def test_from_header |
|
227 | 227 | with_settings :mail_from => 'redmine@example.net' do |
|
228 | 228 | Mailer.test_email(User.find(1)).deliver |
|
229 | 229 | end |
|
230 | 230 | mail = last_email |
|
231 | 231 | assert_equal 'redmine@example.net', mail.from_addrs.first |
|
232 | 232 | end |
|
233 | 233 | |
|
234 | 234 | def test_from_header_with_phrase |
|
235 | 235 | with_settings :mail_from => 'Redmine app <redmine@example.net>' do |
|
236 | 236 | Mailer.test_email(User.find(1)).deliver |
|
237 | 237 | end |
|
238 | 238 | mail = last_email |
|
239 | 239 | assert_equal 'redmine@example.net', mail.from_addrs.first |
|
240 | 240 | assert_equal 'Redmine app <redmine@example.net>', mail.header['From'].to_s |
|
241 | 241 | end |
|
242 | 242 | |
|
243 | 243 | def test_should_not_send_email_without_recipient |
|
244 | 244 | news = News.first |
|
245 | 245 | user = news.author |
|
246 | 246 | # Remove members except news author |
|
247 | 247 | news.project.memberships.each {|m| m.destroy unless m.user == user} |
|
248 | 248 | |
|
249 | 249 | user.pref.no_self_notified = false |
|
250 | 250 | user.pref.save |
|
251 | 251 | User.current = user |
|
252 | 252 | Mailer.news_added(news.reload).deliver |
|
253 | 253 | assert_equal 1, last_email.bcc.size |
|
254 | 254 | |
|
255 | 255 | # nobody to notify |
|
256 | 256 | user.pref.no_self_notified = true |
|
257 | 257 | user.pref.save |
|
258 | 258 | User.current = user |
|
259 | 259 | ActionMailer::Base.deliveries.clear |
|
260 | 260 | Mailer.news_added(news.reload).deliver |
|
261 | 261 | assert ActionMailer::Base.deliveries.empty? |
|
262 | 262 | end |
|
263 | 263 | |
|
264 | 264 | def test_issue_add_message_id |
|
265 | 265 | issue = Issue.find(2) |
|
266 | 266 | Mailer.deliver_issue_add(issue) |
|
267 | 267 | mail = last_email |
|
268 | 268 | assert_match /^redmine\.issue-2\.20060719190421\.[a-f0-9]+@example\.net/, mail.message_id |
|
269 | 269 | assert_include "redmine.issue-2.20060719190421@example.net", mail.references |
|
270 | 270 | end |
|
271 | 271 | |
|
272 | 272 | def test_issue_edit_message_id |
|
273 | 273 | journal = Journal.find(3) |
|
274 | 274 | journal.issue = Issue.find(2) |
|
275 | 275 | |
|
276 | 276 | Mailer.deliver_issue_edit(journal) |
|
277 | 277 | mail = last_email |
|
278 | 278 | assert_match /^redmine\.journal-3\.\d+\.[a-f0-9]+@example\.net/, mail.message_id |
|
279 | 279 | assert_include "redmine.issue-2.20060719190421@example.net", mail.references |
|
280 | 280 | assert_select_email do |
|
281 | 281 | # link to the update |
|
282 | 282 | assert_select "a[href=?]", |
|
283 | 283 | "http://localhost:3000/issues/#{journal.journalized_id}#change-#{journal.id}" |
|
284 | 284 | end |
|
285 | 285 | end |
|
286 | 286 | |
|
287 | 287 | def test_message_posted_message_id |
|
288 | 288 | message = Message.find(1) |
|
289 | 289 | Mailer.message_posted(message).deliver |
|
290 | 290 | mail = last_email |
|
291 | 291 | assert_match /^redmine\.message-1\.\d+\.[a-f0-9]+@example\.net/, mail.message_id |
|
292 | 292 | assert_include "redmine.message-1.20070512151532@example.net", mail.references |
|
293 | 293 | assert_select_email do |
|
294 | 294 | # link to the message |
|
295 | 295 | assert_select "a[href=?]", |
|
296 | 296 | "http://localhost:3000/boards/#{message.board.id}/topics/#{message.id}", |
|
297 | 297 | :text => message.subject |
|
298 | 298 | end |
|
299 | 299 | end |
|
300 | 300 | |
|
301 | 301 | def test_reply_posted_message_id |
|
302 | 302 | message = Message.find(3) |
|
303 | 303 | Mailer.message_posted(message).deliver |
|
304 | 304 | mail = last_email |
|
305 | 305 | assert_match /^redmine\.message-3\.\d+\.[a-f0-9]+@example\.net/, mail.message_id |
|
306 | 306 | assert_include "redmine.message-1.20070512151532@example.net", mail.references |
|
307 | 307 | assert_select_email do |
|
308 | 308 | # link to the reply |
|
309 | 309 | assert_select "a[href=?]", |
|
310 | 310 | "http://localhost:3000/boards/#{message.board.id}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", |
|
311 | 311 | :text => message.subject |
|
312 | 312 | end |
|
313 | 313 | end |
|
314 | 314 | |
|
315 | 315 | test "#issue_add should notify project members" do |
|
316 | 316 | issue = Issue.find(1) |
|
317 | 317 | assert Mailer.deliver_issue_add(issue) |
|
318 | 318 | assert last_email.bcc.include?('dlopper@somenet.foo') |
|
319 | 319 | end |
|
320 | 320 | |
|
321 | 321 | def test_issue_add_should_send_mail_to_all_user_email_address |
|
322 | 322 | EmailAddress.create!(:user_id => 3, :address => 'otheremail@somenet.foo') |
|
323 | 323 | issue = Issue.find(1) |
|
324 | 324 | assert Mailer.deliver_issue_add(issue) |
|
325 | 325 | assert last_email.bcc.include?('dlopper@somenet.foo') |
|
326 | 326 | assert last_email.bcc.include?('otheremail@somenet.foo') |
|
327 | 327 | end |
|
328 | 328 | |
|
329 | 329 | test "#issue_add should not notify project members that are not allow to view the issue" do |
|
330 | 330 | issue = Issue.find(1) |
|
331 | 331 | Role.find(2).remove_permission!(:view_issues) |
|
332 | 332 | assert Mailer.deliver_issue_add(issue) |
|
333 | 333 | assert !last_email.bcc.include?('dlopper@somenet.foo') |
|
334 | 334 | end |
|
335 | 335 | |
|
336 | 336 | test "#issue_add should notify issue watchers" do |
|
337 | 337 | issue = Issue.find(1) |
|
338 | 338 | user = User.find(9) |
|
339 | 339 | # minimal email notification options |
|
340 | 340 | user.pref.no_self_notified = '1' |
|
341 | 341 | user.pref.save |
|
342 | 342 | user.mail_notification = false |
|
343 | 343 | user.save |
|
344 | 344 | |
|
345 | 345 | Watcher.create!(:watchable => issue, :user => user) |
|
346 | 346 | assert Mailer.deliver_issue_add(issue) |
|
347 | 347 | assert last_email.bcc.include?(user.mail) |
|
348 | 348 | end |
|
349 | 349 | |
|
350 | 350 | test "#issue_add should not notify watchers not allowed to view the issue" do |
|
351 | 351 | issue = Issue.find(1) |
|
352 | 352 | user = User.find(9) |
|
353 | 353 | Watcher.create!(:watchable => issue, :user => user) |
|
354 | 354 | Role.non_member.remove_permission!(:view_issues) |
|
355 | 355 | assert Mailer.deliver_issue_add(issue) |
|
356 | 356 | assert !last_email.bcc.include?(user.mail) |
|
357 | 357 | end |
|
358 | 358 | |
|
359 | 359 | def test_issue_add_should_include_enabled_fields |
|
360 | 360 | issue = Issue.find(2) |
|
361 | 361 | assert Mailer.deliver_issue_add(issue) |
|
362 | 362 | assert_mail_body_match '* Target version: 1.0', last_email |
|
363 | 363 | assert_select_email do |
|
364 | 364 | assert_select 'li', :text => 'Target version: 1.0' |
|
365 | 365 | end |
|
366 | 366 | end |
|
367 | 367 | |
|
368 | 368 | def test_issue_add_should_not_include_disabled_fields |
|
369 | 369 | issue = Issue.find(2) |
|
370 | 370 | tracker = issue.tracker |
|
371 | 371 | tracker.core_fields -= ['fixed_version_id'] |
|
372 | 372 | tracker.save! |
|
373 | 373 | assert Mailer.deliver_issue_add(issue) |
|
374 | 374 | assert_mail_body_no_match 'Target version', last_email |
|
375 | 375 | assert_select_email do |
|
376 | 376 | assert_select 'li', :text => /Target version/, :count => 0 |
|
377 | 377 | end |
|
378 | 378 | end |
|
379 | 379 | |
|
380 | 380 | # test mailer methods for each language |
|
381 | 381 | def test_issue_add |
|
382 | 382 | issue = Issue.find(1) |
|
383 | 383 | with_each_language_as_default do |
|
384 | 384 | assert Mailer.deliver_issue_add(issue) |
|
385 | 385 | end |
|
386 | 386 | end |
|
387 | 387 | |
|
388 | 388 | def test_issue_edit |
|
389 | 389 | journal = Journal.find(1) |
|
390 | 390 | with_each_language_as_default do |
|
391 | 391 | assert Mailer.deliver_issue_edit(journal) |
|
392 | 392 | end |
|
393 | 393 | end |
|
394 | 394 | |
|
395 | 395 | def test_issue_edit_should_send_private_notes_to_users_with_permission_only |
|
396 | 396 | journal = Journal.find(1) |
|
397 | 397 | journal.private_notes = true |
|
398 | 398 | journal.save! |
|
399 | 399 | |
|
400 | 400 | Role.find(2).add_permission! :view_private_notes |
|
401 | 401 | Mailer.deliver_issue_edit(journal) |
|
402 | 402 | assert_equal %w(dlopper@somenet.foo jsmith@somenet.foo), ActionMailer::Base.deliveries.last.bcc.sort |
|
403 | 403 | |
|
404 | 404 | Role.find(2).remove_permission! :view_private_notes |
|
405 | 405 | Mailer.deliver_issue_edit(journal) |
|
406 | 406 | assert_equal %w(jsmith@somenet.foo), ActionMailer::Base.deliveries.last.bcc.sort |
|
407 | 407 | end |
|
408 | 408 | |
|
409 | 409 | def test_issue_edit_should_send_private_notes_to_watchers_with_permission_only |
|
410 | 410 | Issue.find(1).set_watcher(User.find_by_login('someone')) |
|
411 | 411 | journal = Journal.find(1) |
|
412 | 412 | journal.private_notes = true |
|
413 | 413 | journal.save! |
|
414 | 414 | |
|
415 | 415 | Role.non_member.add_permission! :view_private_notes |
|
416 | 416 | Mailer.deliver_issue_edit(journal) |
|
417 | 417 | assert_include 'someone@foo.bar', ActionMailer::Base.deliveries.last.bcc.sort |
|
418 | 418 | |
|
419 | 419 | Role.non_member.remove_permission! :view_private_notes |
|
420 | 420 | Mailer.deliver_issue_edit(journal) |
|
421 | 421 | assert_not_include 'someone@foo.bar', ActionMailer::Base.deliveries.last.bcc.sort |
|
422 | 422 | end |
|
423 | 423 | |
|
424 | 424 | def test_issue_edit_should_mark_private_notes |
|
425 | 425 | journal = Journal.find(2) |
|
426 | 426 | journal.private_notes = true |
|
427 | 427 | journal.save! |
|
428 | 428 | |
|
429 | 429 | with_settings :default_language => 'en' do |
|
430 | 430 | Mailer.deliver_issue_edit(journal) |
|
431 | 431 | end |
|
432 | 432 | assert_mail_body_match '(Private notes)', last_email |
|
433 | 433 | end |
|
434 | 434 | |
|
435 | 435 | def test_issue_edit_with_relation_should_notify_users_who_can_see_the_related_issue |
|
436 | 436 | issue = Issue.generate! |
|
437 | 437 | issue.init_journal(User.find(1)) |
|
438 | 438 | private_issue = Issue.generate!(:is_private => true) |
|
439 | 439 | IssueRelation.create!(:issue_from => issue, :issue_to => private_issue, :relation_type => 'relates') |
|
440 | 440 | issue.reload |
|
441 | 441 | assert_equal 1, issue.journals.size |
|
442 | 442 | journal = issue.journals.first |
|
443 | 443 | ActionMailer::Base.deliveries.clear |
|
444 | 444 | |
|
445 | 445 | Mailer.deliver_issue_edit(journal) |
|
446 | 446 | last_email.bcc.each do |email| |
|
447 | 447 | user = User.find_by_mail(email) |
|
448 | 448 | assert private_issue.visible?(user), "Issue was not visible to #{user}" |
|
449 | 449 | end |
|
450 | 450 | end |
|
451 | 451 | |
|
452 | 452 | def test_document_added |
|
453 | 453 | document = Document.find(1) |
|
454 | 454 | with_each_language_as_default do |
|
455 | 455 | assert Mailer.document_added(document).deliver |
|
456 | 456 | end |
|
457 | 457 | end |
|
458 | 458 | |
|
459 | 459 | def test_attachments_added |
|
460 | 460 | attachements = [ Attachment.find_by_container_type('Document') ] |
|
461 | 461 | with_each_language_as_default do |
|
462 | 462 | assert Mailer.attachments_added(attachements).deliver |
|
463 | 463 | end |
|
464 | 464 | end |
|
465 | 465 | |
|
466 | 466 | def test_version_file_added |
|
467 | 467 | attachements = [ Attachment.find_by_container_type('Version') ] |
|
468 | 468 | assert Mailer.attachments_added(attachements).deliver |
|
469 | 469 | assert_not_nil last_email.bcc |
|
470 | 470 | assert last_email.bcc.any? |
|
471 | 471 | assert_select_email do |
|
472 | 472 | assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" |
|
473 | 473 | end |
|
474 | 474 | end |
|
475 | 475 | |
|
476 | 476 | def test_project_file_added |
|
477 | 477 | attachements = [ Attachment.find_by_container_type('Project') ] |
|
478 | 478 | assert Mailer.attachments_added(attachements).deliver |
|
479 | 479 | assert_not_nil last_email.bcc |
|
480 | 480 | assert last_email.bcc.any? |
|
481 | 481 | assert_select_email do |
|
482 | 482 | assert_select "a[href=?]", "http://localhost:3000/projects/ecookbook/files" |
|
483 | 483 | end |
|
484 | 484 | end |
|
485 | 485 | |
|
486 | 486 | def test_news_added |
|
487 | 487 | news = News.first |
|
488 | 488 | with_each_language_as_default do |
|
489 | 489 | assert Mailer.news_added(news).deliver |
|
490 | 490 | end |
|
491 | 491 | end |
|
492 | 492 | |
|
493 | 493 | def test_news_added_should_notify_project_news_watchers |
|
494 | 494 | user1 = User.generate! |
|
495 | 495 | user2 = User.generate! |
|
496 | 496 | news = News.find(1) |
|
497 | 497 | news.project.enabled_module('news').add_watcher(user1) |
|
498 | 498 | |
|
499 | 499 | Mailer.news_added(news).deliver |
|
500 | 500 | assert_include user1.mail, last_email.bcc |
|
501 | 501 | assert_not_include user2.mail, last_email.bcc |
|
502 | 502 | end |
|
503 | 503 | |
|
504 | 504 | def test_news_comment_added |
|
505 | 505 | comment = Comment.find(2) |
|
506 | 506 | with_each_language_as_default do |
|
507 | 507 | assert Mailer.news_comment_added(comment).deliver |
|
508 | 508 | end |
|
509 | 509 | end |
|
510 | 510 | |
|
511 | 511 | def test_message_posted |
|
512 | 512 | message = Message.first |
|
513 | 513 | recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author} |
|
514 | 514 | recipients = recipients.compact.uniq |
|
515 | 515 | with_each_language_as_default do |
|
516 | 516 | assert Mailer.message_posted(message).deliver |
|
517 | 517 | end |
|
518 | 518 | end |
|
519 | 519 | |
|
520 | 520 | def test_wiki_content_added |
|
521 | 521 | content = WikiContent.find(1) |
|
522 | 522 | with_each_language_as_default do |
|
523 | 523 | assert_difference 'ActionMailer::Base.deliveries.size' do |
|
524 | 524 | assert Mailer.wiki_content_added(content).deliver |
|
525 | 525 | assert_select_email do |
|
526 | 526 | assert_select 'a[href=?]', |
|
527 | 527 | 'http://localhost:3000/projects/ecookbook/wiki/CookBook_documentation', |
|
528 | 528 | :text => 'CookBook documentation' |
|
529 | 529 | end |
|
530 | 530 | end |
|
531 | 531 | end |
|
532 | 532 | end |
|
533 | 533 | |
|
534 | 534 | def test_wiki_content_updated |
|
535 | 535 | content = WikiContent.find(1) |
|
536 | 536 | with_each_language_as_default do |
|
537 | 537 | assert_difference 'ActionMailer::Base.deliveries.size' do |
|
538 | 538 | assert Mailer.wiki_content_updated(content).deliver |
|
539 | 539 | assert_select_email do |
|
540 | 540 | assert_select 'a[href=?]', |
|
541 | 541 | 'http://localhost:3000/projects/ecookbook/wiki/CookBook_documentation', |
|
542 | 542 | :text => 'CookBook documentation' |
|
543 | 543 | end |
|
544 | 544 | end |
|
545 | 545 | end |
|
546 | 546 | end |
|
547 | 547 | |
|
548 | 548 | def test_account_information |
|
549 | 549 | user = User.find(2) |
|
550 | 550 | valid_languages.each do |lang| |
|
551 | 551 | user.update_attribute :language, lang.to_s |
|
552 | 552 | user.reload |
|
553 | 553 | assert Mailer.account_information(user, 'pAsswORd').deliver |
|
554 | 554 | end |
|
555 | 555 | end |
|
556 | 556 | |
|
557 | 557 | def test_lost_password |
|
558 | 558 | token = Token.find(2) |
|
559 | 559 | valid_languages.each do |lang| |
|
560 | 560 | token.user.update_attribute :language, lang.to_s |
|
561 | 561 | token.reload |
|
562 | 562 | assert Mailer.lost_password(token).deliver |
|
563 | 563 | end |
|
564 | 564 | end |
|
565 | 565 | |
|
566 | 566 | def test_register |
|
567 | 567 | token = Token.find(1) |
|
568 | 568 | valid_languages.each do |lang| |
|
569 | 569 | token.user.update_attribute :language, lang.to_s |
|
570 | 570 | token.reload |
|
571 | 571 | ActionMailer::Base.deliveries.clear |
|
572 | 572 | assert Mailer.register(token).deliver |
|
573 | 573 | mail = last_email |
|
574 | 574 | assert_select_email do |
|
575 | 575 | assert_select "a[href=?]", |
|
576 | 576 | "http://localhost:3000/account/activate?token=#{token.value}", |
|
577 | 577 | :text => "http://localhost:3000/account/activate?token=#{token.value}" |
|
578 | 578 | end |
|
579 | 579 | end |
|
580 | 580 | end |
|
581 | 581 | |
|
582 | 582 | def test_test |
|
583 | 583 | user = User.find(1) |
|
584 | 584 | valid_languages.each do |lang| |
|
585 | 585 | user.update_attribute :language, lang.to_s |
|
586 | 586 | assert Mailer.test_email(user).deliver |
|
587 | 587 | end |
|
588 | 588 | end |
|
589 | 589 | |
|
590 | 590 | def test_reminders |
|
591 | 591 | Mailer.reminders(:days => 42) |
|
592 | 592 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
593 | 593 | mail = last_email |
|
594 | 594 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
595 | 595 | assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail |
|
596 | 596 | assert_equal '1 issue(s) due in the next 42 days', mail.subject |
|
597 | 597 | end |
|
598 | 598 | |
|
599 | 599 | def test_reminders_should_not_include_closed_issues |
|
600 | 600 | with_settings :default_language => 'en' do |
|
601 | 601 | Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 5, |
|
602 | 602 | :subject => 'Closed issue', :assigned_to_id => 3, |
|
603 | 603 | :due_date => 5.days.from_now, |
|
604 | 604 | :author_id => 2) |
|
605 | 605 | ActionMailer::Base.deliveries.clear |
|
606 | 606 | |
|
607 | 607 | Mailer.reminders(:days => 42) |
|
608 | 608 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
609 | 609 | mail = last_email |
|
610 | 610 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
611 | 611 | assert_mail_body_no_match 'Closed issue', mail |
|
612 | 612 | end |
|
613 | 613 | end |
|
614 | 614 | |
|
615 | 615 | def test_reminders_for_users |
|
616 | 616 | Mailer.reminders(:days => 42, :users => ['5']) |
|
617 | 617 | assert_equal 0, ActionMailer::Base.deliveries.size # No mail for dlopper |
|
618 | 618 | Mailer.reminders(:days => 42, :users => ['3']) |
|
619 | 619 | assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper |
|
620 | 620 | mail = last_email |
|
621 | 621 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
622 | 622 | assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail |
|
623 | 623 | end |
|
624 | 624 | |
|
625 | 625 | def test_reminder_should_include_issues_assigned_to_groups |
|
626 | 626 | with_settings :default_language => 'en' do |
|
627 | 627 | group = Group.generate! |
|
628 | 628 | group.users << User.find(2) |
|
629 | 629 | group.users << User.find(3) |
|
630 | 630 | |
|
631 | 631 | Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1, |
|
632 | 632 | :subject => 'Assigned to group', :assigned_to => group, |
|
633 | 633 | :due_date => 5.days.from_now, |
|
634 | 634 | :author_id => 2) |
|
635 | 635 | ActionMailer::Base.deliveries.clear |
|
636 | 636 | |
|
637 | 637 | Mailer.reminders(:days => 7) |
|
638 | 638 | assert_equal 2, ActionMailer::Base.deliveries.size |
|
639 | 639 | assert_equal %w(dlopper@somenet.foo jsmith@somenet.foo), ActionMailer::Base.deliveries.map(&:bcc).flatten.sort |
|
640 | 640 | ActionMailer::Base.deliveries.each do |mail| |
|
641 | 641 | assert_mail_body_match 'Assigned to group', mail |
|
642 | 642 | end |
|
643 | 643 | end |
|
644 | 644 | end |
|
645 | 645 | |
|
646 | 646 | def test_reminders_with_version_option |
|
647 | 647 | with_settings :default_language => 'en' do |
|
648 | 648 | version = Version.generate!(:name => 'Acme', :project_id => 1) |
|
649 | 649 | Issue.generate!(:assigned_to => User.find(2), :due_date => 5.days.from_now) |
|
650 | 650 | Issue.generate!(:assigned_to => User.find(3), :due_date => 5.days.from_now, :fixed_version => version) |
|
651 | 651 | ActionMailer::Base.deliveries.clear |
|
652 | 652 | |
|
653 | 653 | Mailer.reminders(:days => 42, :version => 'acme') |
|
654 | 654 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
655 | 655 | |
|
656 | 656 | mail = last_email |
|
657 | 657 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
658 | 658 | end |
|
659 | 659 | end |
|
660 | 660 | |
|
661 | 661 | def test_security_notification |
|
662 | 662 | set_language_if_valid User.find(1).language |
|
663 | 663 | with_settings :emails_footer => "footer without link" do |
|
664 | 664 | User.current.remote_ip = '192.168.1.1' |
|
665 | 665 | assert Mailer.security_notification(User.find(1), message: :notice_account_password_updated).deliver |
|
666 | 666 | mail = last_email |
|
667 | 667 | assert_not_nil mail |
|
668 | 668 | assert_mail_body_match '192.168.1.1', mail |
|
669 | 669 | assert_mail_body_match I18n.t(:notice_account_password_updated), mail |
|
670 | 670 | assert_select_email do |
|
671 | 671 | assert_select "h1", false |
|
672 | 672 | assert_select "a", false |
|
673 | 673 | end |
|
674 | 674 | end |
|
675 | 675 | end |
|
676 | 676 | |
|
677 | 677 | def test_security_notification_should_include_title |
|
678 | 678 | set_language_if_valid User.find(2).language |
|
679 | 679 | with_settings :emails_footer => "footer without link" do |
|
680 | 680 | assert Mailer.security_notification(User.find(2), |
|
681 | 681 | message: :notice_account_password_updated, |
|
682 | 682 | title: :label_my_account |
|
683 | 683 | ).deliver |
|
684 | 684 | assert_select_email do |
|
685 | 685 | assert_select "a", false |
|
686 | 686 | assert_select "h1", :text => I18n.t(:label_my_account) |
|
687 | 687 | end |
|
688 | 688 | end |
|
689 | 689 | end |
|
690 | 690 | |
|
691 | 691 | def test_security_notification_should_include_link |
|
692 | 692 | set_language_if_valid User.find(3).language |
|
693 | 693 | with_settings :emails_footer => "footer without link" do |
|
694 | 694 | assert Mailer.security_notification(User.find(3), |
|
695 | 695 | message: :notice_account_password_updated, |
|
696 | 696 | title: :label_my_account, |
|
697 | 697 | url: {controller: 'my', action: 'account'} |
|
698 | 698 | ).deliver |
|
699 | 699 | assert_select_email do |
|
700 | 700 | assert_select "h1", false |
|
701 | 701 | assert_select 'a[href=?]', 'http://localhost:3000/my/account', :text => I18n.t(:label_my_account) |
|
702 | 702 | end |
|
703 | 703 | end |
|
704 | 704 | end |
|
705 | 705 | |
|
706 | 706 | def test_mailer_should_not_change_locale |
|
707 | 707 | # Set current language to italian |
|
708 | 708 | set_language_if_valid 'it' |
|
709 | 709 | # Send an email to a french user |
|
710 | 710 | user = User.find(1) |
|
711 | 711 | user.language = 'fr' |
|
712 | 712 | Mailer.account_activated(user).deliver |
|
713 | 713 | mail = last_email |
|
714 | 714 | assert_mail_body_match 'Votre compte', mail |
|
715 | 715 | |
|
716 | 716 | assert_equal :it, current_language |
|
717 | 717 | end |
|
718 | 718 | |
|
719 | 719 | def test_with_deliveries_off |
|
720 | 720 | Mailer.with_deliveries false do |
|
721 | 721 | Mailer.test_email(User.find(1)).deliver |
|
722 | 722 | end |
|
723 | 723 | assert ActionMailer::Base.deliveries.empty? |
|
724 | 724 | # should restore perform_deliveries |
|
725 | 725 | assert ActionMailer::Base.perform_deliveries |
|
726 | 726 | end |
|
727 | 727 | |
|
728 | 728 | def test_token_for_should_strip_trailing_gt_from_address_with_full_name |
|
729 | 729 | with_settings :mail_from => "Redmine Mailer<no-reply@redmine.org>" do |
|
730 | 730 | assert_match /\Aredmine.issue-\d+\.\d+\.[0-9a-f]+@redmine.org\z/, Mailer.token_for(Issue.generate!) |
|
731 | 731 | end |
|
732 | 732 | end |
|
733 | 733 | |
|
734 | 734 | def test_layout_should_include_the_emails_header |
|
735 | 735 | with_settings :emails_header => "*Header content*" do |
|
736 | 736 | with_settings :plain_text_mail => 0 do |
|
737 | 737 | assert Mailer.test_email(User.find(1)).deliver |
|
738 | 738 | assert_select_email do |
|
739 | 739 | assert_select ".header" do |
|
740 | 740 | assert_select "strong", :text => "Header content" |
|
741 | 741 | end |
|
742 | 742 | end |
|
743 | 743 | end |
|
744 | 744 | with_settings :plain_text_mail => 1 do |
|
745 | 745 | assert Mailer.test_email(User.find(1)).deliver |
|
746 | 746 | mail = last_email |
|
747 | 747 | assert_not_nil mail |
|
748 | 748 | assert_include "*Header content*", mail.body.decoded |
|
749 | 749 | end |
|
750 | 750 | end |
|
751 | 751 | end |
|
752 | 752 | |
|
753 | 753 | def test_layout_should_not_include_empty_emails_header |
|
754 | 754 | with_settings :emails_header => "", :plain_text_mail => 0 do |
|
755 | 755 | assert Mailer.test_email(User.find(1)).deliver |
|
756 | 756 | assert_select_email do |
|
757 | 757 | assert_select ".header", false |
|
758 | 758 | end |
|
759 | 759 | end |
|
760 | 760 | end |
|
761 | 761 | |
|
762 | 762 | def test_layout_should_include_the_emails_footer |
|
763 | 763 | with_settings :emails_footer => "*Footer content*" do |
|
764 | 764 | with_settings :plain_text_mail => 0 do |
|
765 | 765 | assert Mailer.test_email(User.find(1)).deliver |
|
766 | 766 | assert_select_email do |
|
767 | 767 | assert_select ".footer" do |
|
768 | 768 | assert_select "strong", :text => "Footer content" |
|
769 | 769 | end |
|
770 | 770 | end |
|
771 | 771 | end |
|
772 | 772 | with_settings :plain_text_mail => 1 do |
|
773 | 773 | assert Mailer.test_email(User.find(1)).deliver |
|
774 | 774 | mail = last_email |
|
775 | 775 | assert_not_nil mail |
|
776 | 776 | assert_include "\n-- \n", mail.body.decoded |
|
777 | 777 | assert_include "*Footer content*", mail.body.decoded |
|
778 | 778 | end |
|
779 | 779 | end |
|
780 | 780 | end |
|
781 | 781 | |
|
782 | 782 | def test_layout_should_not_include_empty_emails_footer |
|
783 | 783 | with_settings :emails_footer => "" do |
|
784 | 784 | with_settings :plain_text_mail => 0 do |
|
785 | 785 | assert Mailer.test_email(User.find(1)).deliver |
|
786 | 786 | assert_select_email do |
|
787 | 787 | assert_select ".footer", false |
|
788 | 788 | end |
|
789 | 789 | end |
|
790 | 790 | with_settings :plain_text_mail => 1 do |
|
791 | 791 | assert Mailer.test_email(User.find(1)).deliver |
|
792 | 792 | mail = last_email |
|
793 | 793 | assert_not_nil mail |
|
794 | 794 | assert_not_include "\n-- \n", mail.body.decoded |
|
795 | 795 | end |
|
796 | 796 | end |
|
797 | 797 | end |
|
798 | 798 | |
|
799 | 799 | def test_should_escape_html_templates_only |
|
800 | 800 | Issue.generate!(:project_id => 1, :tracker_id => 1, :subject => 'Subject with a <tag>') |
|
801 | 801 | mail = last_email |
|
802 | 802 | assert_equal 2, mail.parts.size |
|
803 | 803 | assert_include '<tag>', text_part.body.encoded |
|
804 | 804 | assert_include '<tag>', html_part.body.encoded |
|
805 | 805 | end |
|
806 | 806 | |
|
807 | 807 | def test_should_raise_delivery_errors_when_raise_delivery_errors_is_true |
|
808 | 808 | mail = Mailer.test_email(User.find(1)) |
|
809 | 809 | mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error")) |
|
810 | 810 | |
|
811 | 811 | ActionMailer::Base.raise_delivery_errors = true |
|
812 | 812 | assert_raise Exception, "delivery error" do |
|
813 | 813 | mail.deliver |
|
814 | 814 | end |
|
815 | 815 | ensure |
|
816 | 816 | ActionMailer::Base.raise_delivery_errors = false |
|
817 | 817 | end |
|
818 | 818 | |
|
819 | 819 | def test_should_log_delivery_errors_when_raise_delivery_errors_is_false |
|
820 | 820 | mail = Mailer.test_email(User.find(1)) |
|
821 | 821 | mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error")) |
|
822 | 822 | |
|
823 | 823 | Rails.logger.expects(:error).with("Email delivery error: delivery error") |
|
824 | 824 | ActionMailer::Base.raise_delivery_errors = false |
|
825 | 825 | assert_nothing_raised do |
|
826 | 826 | mail.deliver |
|
827 | 827 | end |
|
828 | 828 | end |
|
829 | 829 | |
|
830 | 830 | def test_with_synched_deliveries_should_yield_with_synced_deliveries |
|
831 | 831 | ActionMailer::Base.delivery_method = :async_smtp |
|
832 | 832 | ActionMailer::Base.async_smtp_settings = {:foo => 'bar'} |
|
833 | 833 | |
|
834 | 834 | Mailer.with_synched_deliveries do |
|
835 | 835 | assert_equal :smtp, ActionMailer::Base.delivery_method |
|
836 | 836 | assert_equal({:foo => 'bar'}, ActionMailer::Base.smtp_settings) |
|
837 | 837 | end |
|
838 | 838 | assert_equal :async_smtp, ActionMailer::Base.delivery_method |
|
839 | 839 | ensure |
|
840 | 840 | ActionMailer::Base.delivery_method = :test |
|
841 | 841 | end |
|
842 | 842 | |
|
843 | 843 | def test_email_addresses_should_keep_addresses |
|
844 | 844 | assert_equal ["foo@example.net"], |
|
845 | 845 | Mailer.email_addresses("foo@example.net") |
|
846 | 846 | |
|
847 | 847 | assert_equal ["foo@example.net", "bar@example.net"], |
|
848 | 848 | Mailer.email_addresses(["foo@example.net", "bar@example.net"]) |
|
849 | 849 | end |
|
850 | 850 | |
|
851 | 851 | def test_email_addresses_should_replace_users_with_their_email_addresses |
|
852 | 852 | assert_equal ["admin@somenet.foo"], |
|
853 | 853 | Mailer.email_addresses(User.find(1)) |
|
854 | 854 | |
|
855 | 855 | assert_equal ["admin@somenet.foo", "jsmith@somenet.foo"], |
|
856 | 856 | Mailer.email_addresses(User.where(:id => [1,2])).sort |
|
857 | 857 | end |
|
858 | 858 | |
|
859 | 859 | def test_email_addresses_should_include_notified_emails_addresses_only |
|
860 | 860 | EmailAddress.create!(:user_id => 2, :address => "another@somenet.foo", :notify => false) |
|
861 | 861 | EmailAddress.create!(:user_id => 2, :address => "another2@somenet.foo") |
|
862 | 862 | |
|
863 | 863 | assert_equal ["another2@somenet.foo", "jsmith@somenet.foo"], |
|
864 | 864 | Mailer.email_addresses(User.find(2)).sort |
|
865 | 865 | end |
|
866 | 866 | |
|
867 | 867 | private |
|
868 | 868 | |
|
869 | 869 | def last_email |
|
870 | 870 | mail = ActionMailer::Base.deliveries.last |
|
871 | 871 | assert_not_nil mail |
|
872 | 872 | |
|
873 | 873 | end |
|
874 | 874 | |
|
875 | 875 | def text_part |
|
876 | 876 | last_email.parts.detect {|part| part.content_type.include?('text/plain')} |
|
877 | 877 | end |
|
878 | 878 | |
|
879 | 879 | def html_part |
|
880 | 880 | last_email.parts.detect {|part| part.content_type.include?('text/html')} |
|
881 | 881 | end |
|
882 | 882 | |
|
883 | 883 | def with_each_language_as_default(&block) |
|
884 | 884 | valid_languages.each do |lang| |
|
885 | 885 | with_settings :default_language => lang.to_s do |
|
886 | 886 | yield lang |
|
887 | 887 | end |
|
888 | 888 | end |
|
889 | 889 | end |
|
890 | 890 | end |
General Comments 0
You need to be logged in to leave comments.
Login now