@@ -74,7 +74,7 class FilesControllerTest < ActionController::TestCase | |||||
74 | mail = ActionMailer::Base.deliveries.last |
|
74 | mail = ActionMailer::Base.deliveries.last | |
75 | assert_not_nil mail |
|
75 | assert_not_nil mail | |
76 | assert_equal "[eCookbook] New file", mail.subject |
|
76 | assert_equal "[eCookbook] New file", mail.subject | |
77 |
assert mail |
|
77 | assert_mail_body_match 'testfile.txt', mail | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_create_version_file |
|
80 | def test_create_version_file |
@@ -2164,7 +2164,7 class IssuesControllerTest < ActionController::TestCase | |||||
2164 | mail = ActionMailer::Base.deliveries.last |
|
2164 | mail = ActionMailer::Base.deliveries.last | |
2165 | assert_not_nil mail |
|
2165 | assert_not_nil mail | |
2166 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2166 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") | |
2167 |
assert |
|
2167 | assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail | |
2168 | end |
|
2168 | end | |
2169 |
|
2169 | |||
2170 | def test_put_update_with_project_change |
|
2170 | def test_put_update_with_project_change | |
@@ -2190,7 +2190,7 class IssuesControllerTest < ActionController::TestCase | |||||
2190 | mail = ActionMailer::Base.deliveries.last |
|
2190 | mail = ActionMailer::Base.deliveries.last | |
2191 | assert_not_nil mail |
|
2191 | assert_not_nil mail | |
2192 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2192 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") | |
2193 |
assert |
|
2193 | assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail | |
2194 | end |
|
2194 | end | |
2195 |
|
2195 | |||
2196 | def test_put_update_with_tracker_change |
|
2196 | def test_put_update_with_tracker_change | |
@@ -2215,7 +2215,7 class IssuesControllerTest < ActionController::TestCase | |||||
2215 | mail = ActionMailer::Base.deliveries.last |
|
2215 | mail = ActionMailer::Base.deliveries.last | |
2216 | assert_not_nil mail |
|
2216 | assert_not_nil mail | |
2217 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2217 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") | |
2218 |
assert |
|
2218 | assert_mail_body_match "Tracker changed from Bug to Feature request", mail | |
2219 | end |
|
2219 | end | |
2220 |
|
2220 | |||
2221 | def test_put_update_with_custom_field_change |
|
2221 | def test_put_update_with_custom_field_change | |
@@ -2238,7 +2238,7 class IssuesControllerTest < ActionController::TestCase | |||||
2238 |
|
2238 | |||
2239 | mail = ActionMailer::Base.deliveries.last |
|
2239 | mail = ActionMailer::Base.deliveries.last | |
2240 | assert_not_nil mail |
|
2240 | assert_not_nil mail | |
2241 |
assert |
|
2241 | assert_mail_body_match "Searchable field changed from 125 to New custom value", mail | |
2242 | end |
|
2242 | end | |
2243 |
|
2243 | |||
2244 | def test_put_update_with_multi_custom_field_change |
|
2244 | def test_put_update_with_multi_custom_field_change | |
@@ -2281,7 +2281,7 class IssuesControllerTest < ActionController::TestCase | |||||
2281 | assert_equal 2, j.details.size |
|
2281 | assert_equal 2, j.details.size | |
2282 |
|
2282 | |||
2283 | mail = ActionMailer::Base.deliveries.last |
|
2283 | mail = ActionMailer::Base.deliveries.last | |
2284 |
assert |
|
2284 | assert_mail_body_match "Status changed from New to Assigned", mail | |
2285 | # subject should contain the new status |
|
2285 | # subject should contain the new status | |
2286 | assert mail.subject.include?("(#{ IssueStatus.find(2).name })") |
|
2286 | assert mail.subject.include?("(#{ IssueStatus.find(2).name })") | |
2287 | end |
|
2287 | end | |
@@ -2299,7 +2299,7 class IssuesControllerTest < ActionController::TestCase | |||||
2299 | assert_equal User.anonymous, j.user |
|
2299 | assert_equal User.anonymous, j.user | |
2300 |
|
2300 | |||
2301 | mail = ActionMailer::Base.deliveries.last |
|
2301 | mail = ActionMailer::Base.deliveries.last | |
2302 | assert mail.body.include?(notes) |
|
2302 | assert_mail_body_match notes, mail | |
2303 | end |
|
2303 | end | |
2304 |
|
2304 | |||
2305 | def test_put_update_with_note_and_spent_time |
|
2305 | def test_put_update_with_note_and_spent_time | |
@@ -2357,7 +2357,7 class IssuesControllerTest < ActionController::TestCase | |||||
2357 | assert_equal 59, File.size(attachment.diskfile) |
|
2357 | assert_equal 59, File.size(attachment.diskfile) | |
2358 |
|
2358 | |||
2359 | mail = ActionMailer::Base.deliveries.last |
|
2359 | mail = ActionMailer::Base.deliveries.last | |
2360 |
assert mail |
|
2360 | assert_mail_body_match 'testfile.txt', mail | |
2361 | end |
|
2361 | end | |
2362 |
|
2362 | |||
2363 | def test_put_update_with_failure_should_save_attachments |
|
2363 | def test_put_update_with_failure_should_save_attachments |
@@ -106,7 +106,7 class MessagesControllerTest < ActionController::TestCase | |||||
106 | mail = ActionMailer::Base.deliveries.last |
|
106 | mail = ActionMailer::Base.deliveries.last | |
107 | assert_not_nil mail |
|
107 | assert_not_nil mail | |
108 | assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject |
|
108 | assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject | |
109 |
assert mail |
|
109 | assert_mail_body_match 'Message body', mail | |
110 | # author |
|
110 | # author | |
111 | assert mail.bcc.include?('jsmith@somenet.foo') |
|
111 | assert mail.bcc.include?('jsmith@somenet.foo') | |
112 | # project member |
|
112 | # project member |
@@ -191,7 +191,7 class UsersControllerTest < ActionController::TestCase | |||||
191 | mail = ActionMailer::Base.deliveries.last |
|
191 | mail = ActionMailer::Base.deliveries.last | |
192 | assert_not_nil mail |
|
192 | assert_not_nil mail | |
193 | assert_equal [user.mail], mail.bcc |
|
193 | assert_equal [user.mail], mail.bcc | |
194 |
assert mail |
|
194 | assert_mail_body_match 'secret', mail | |
195 | end |
|
195 | end | |
196 |
|
196 | |||
197 | def test_create_with_preferences |
|
197 | def test_create_with_preferences | |
@@ -279,7 +279,7 class UsersControllerTest < ActionController::TestCase | |||||
279 | mail = ActionMailer::Base.deliveries.last |
|
279 | mail = ActionMailer::Base.deliveries.last | |
280 | assert_not_nil mail |
|
280 | assert_not_nil mail | |
281 | assert_equal ['foo.bar@somenet.foo'], mail.bcc |
|
281 | assert_equal ['foo.bar@somenet.foo'], mail.bcc | |
282 |
assert |
|
282 | assert_mail_body_match ll('fr', :notice_account_activated), mail | |
283 | end |
|
283 | end | |
284 |
|
284 | |||
285 | def test_update_with_password_change_should_send_a_notification |
|
285 | def test_update_with_password_change_should_send_a_notification | |
@@ -293,7 +293,7 class UsersControllerTest < ActionController::TestCase | |||||
293 | mail = ActionMailer::Base.deliveries.last |
|
293 | mail = ActionMailer::Base.deliveries.last | |
294 | assert_not_nil mail |
|
294 | assert_not_nil mail | |
295 | assert_equal [u.mail], mail.bcc |
|
295 | assert_equal [u.mail], mail.bcc | |
296 |
assert mail |
|
296 | assert_mail_body_match 'newpass', mail | |
297 | end |
|
297 | end | |
298 |
|
298 | |||
299 | test "put :update with a password change to an AuthSource user switching to Internal authentication" do |
|
299 | test "put :update with a password change to an AuthSource user switching to Internal authentication" do |
@@ -158,6 +158,26 class ActiveSupport::TestCase | |||||
158 | assert s.include?(expected), "\"#{expected}\" not found in \"#{s}\"" |
|
158 | assert s.include?(expected), "\"#{expected}\" not found in \"#{s}\"" | |
159 | end |
|
159 | end | |
160 |
|
160 | |||
|
161 | def assert_not_include(expected, s) | |||
|
162 | assert !s.include?(expected), "\"#{expected}\" found in \"#{s}\"" | |||
|
163 | end | |||
|
164 | ||||
|
165 | def assert_mail_body_match(expected, mail) | |||
|
166 | if expected.is_a?(String) | |||
|
167 | assert_include expected, mail.body | |||
|
168 | else | |||
|
169 | assert_match expected, mail.body | |||
|
170 | end | |||
|
171 | end | |||
|
172 | ||||
|
173 | def assert_mail_body_no_match(expected, mail) | |||
|
174 | if expected.is_a?(String) | |||
|
175 | assert_not_include expected, mail.body | |||
|
176 | else | |||
|
177 | assert_no_match expected, mail.body | |||
|
178 | end | |||
|
179 | end | |||
|
180 | ||||
161 | # Shoulda macros |
|
181 | # Shoulda macros | |
162 | def self.should_render_404 |
|
182 | def self.should_render_404 | |
163 | should_respond_with :not_found |
|
183 | should_respond_with :not_found |
@@ -470,7 +470,7 class MailerTest < ActiveSupport::TestCase | |||||
470 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
470 | assert_equal 1, ActionMailer::Base.deliveries.size | |
471 | mail = last_email |
|
471 | mail = last_email | |
472 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
472 | assert mail.bcc.include?('dlopper@somenet.foo') | |
473 |
assert mail |
|
473 | assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail | |
474 | assert_equal '1 issue(s) due in the next 42 days', mail.subject |
|
474 | assert_equal '1 issue(s) due in the next 42 days', mail.subject | |
475 | end |
|
475 | end | |
476 |
|
476 | |||
@@ -486,7 +486,7 class MailerTest < ActiveSupport::TestCase | |||||
486 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
486 | assert_equal 1, ActionMailer::Base.deliveries.size | |
487 | mail = last_email |
|
487 | mail = last_email | |
488 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
488 | assert mail.bcc.include?('dlopper@somenet.foo') | |
489 |
assert |
|
489 | assert_mail_body_no_match 'Closed issue', mail | |
490 | end |
|
490 | end | |
491 | end |
|
491 | end | |
492 |
|
492 | |||
@@ -497,7 +497,7 class MailerTest < ActiveSupport::TestCase | |||||
497 | assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper |
|
497 | assert_equal 1, ActionMailer::Base.deliveries.size # No mail for dlopper | |
498 | mail = last_email |
|
498 | mail = last_email | |
499 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
499 | assert mail.bcc.include?('dlopper@somenet.foo') | |
500 |
assert mail |
|
500 | assert_mail_body_match 'Bug #3: Error 281 when updating a recipe', mail | |
501 | end |
|
501 | end | |
502 |
|
502 | |||
503 | def last_email |
|
503 | def last_email | |
@@ -515,7 +515,7 class MailerTest < ActiveSupport::TestCase | |||||
515 | user.language = 'fr' |
|
515 | user.language = 'fr' | |
516 | Mailer.deliver_account_activated(user) |
|
516 | Mailer.deliver_account_activated(user) | |
517 | mail = last_email |
|
517 | mail = last_email | |
518 |
assert mail |
|
518 | assert_mail_body_match 'Votre compte', mail | |
519 |
|
519 | |||
520 | assert_equal :it, current_language |
|
520 | assert_equal :it, current_language | |
521 | end |
|
521 | end |
@@ -176,8 +176,8 class RepositoryTest < ActiveSupport::TestCase | |||||
176 | assert_not_nil mail |
|
176 | assert_not_nil mail | |
177 | assert mail.subject.starts_with?( |
|
177 | assert mail.subject.starts_with?( | |
178 | "[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]") |
|
178 | "[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]") | |
179 |
assert |
|
179 | assert_mail_body_match( | |
180 | "Status changed from #{old_status} to #{fixed_issue.status}") |
|
180 | "Status changed from #{old_status} to #{fixed_issue.status}", mail) | |
181 |
|
181 | |||
182 | # ignoring commits referencing an issue of another project |
|
182 | # ignoring commits referencing an issue of another project | |
183 | assert_equal [], Issue.find(4).changesets |
|
183 | assert_equal [], Issue.find(4).changesets |
General Comments 0
You need to be logged in to leave comments.
Login now