Adds an helper to get the body of an email in tests.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9092 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
67d52acb84
commit
df89c24e37
|
@ -164,20 +164,24 @@ class ActiveSupport::TestCase
|
||||||
|
|
||||||
def assert_mail_body_match(expected, mail)
|
def assert_mail_body_match(expected, mail)
|
||||||
if expected.is_a?(String)
|
if expected.is_a?(String)
|
||||||
assert_include expected, mail.body
|
assert_include expected, mail_body(mail)
|
||||||
else
|
else
|
||||||
assert_match expected, mail.body
|
assert_match expected, mail_body(mail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_mail_body_no_match(expected, mail)
|
def assert_mail_body_no_match(expected, mail)
|
||||||
if expected.is_a?(String)
|
if expected.is_a?(String)
|
||||||
assert_not_include expected, mail.body
|
assert_not_include expected, mail_body(mail)
|
||||||
else
|
else
|
||||||
assert_no_match expected, mail.body
|
assert_no_match expected, mail_body(mail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mail_body(mail)
|
||||||
|
mail.body
|
||||||
|
end
|
||||||
|
|
||||||
# Shoulda macros
|
# Shoulda macros
|
||||||
def self.should_render_404
|
def self.should_render_404
|
||||||
should_respond_with :not_found
|
should_respond_with :not_found
|
||||||
|
|
|
@ -158,7 +158,7 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
|
||||||
Mailer.deliver_issue_add(issue)
|
Mailer.deliver_issue_add(issue)
|
||||||
mail2 = ActionMailer::Base.deliveries.last
|
mail2 = ActionMailer::Base.deliveries.last
|
||||||
|
|
||||||
assert_equal mail.body, mail2.body
|
assert_equal mail_body(mail), mail_body(mail2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def hook_helper
|
def hook_helper
|
||||||
|
|
|
@ -272,8 +272,8 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
email = ActionMailer::Base.deliveries.first
|
email = ActionMailer::Base.deliveries.first
|
||||||
assert_not_nil email
|
assert_not_nil email
|
||||||
assert email.subject.include?('account activation')
|
assert email.subject.include?('account activation')
|
||||||
login = email.body.match(/\* Login: (.*)$/)[1]
|
login = mail_body(email).match(/\* Login: (.*)$/)[1]
|
||||||
password = email.body.match(/\* Password: (.*)$/)[1]
|
password = mail_body(email).match(/\* Password: (.*)$/)[1]
|
||||||
assert_equal issue.author, User.try_to_login(login, password)
|
assert_equal issue.author, User.try_to_login(login, password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue