summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-04 14:01:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-04 14:01:54 +0000
commitdf89c24e37af13fac084b44ae5f3f40769d7aa24 (patch)
tree15198adb07ea66838cf6554848194fe173783878
parent67d52acb848252d0f51045914f5219311ef01092 (diff)
downloadredmine-df89c24e37af13fac084b44ae5f3f40769d7aa24.tar.gz
redmine-df89c24e37af13fac084b44ae5f3f40769d7aa24.zip
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
-rw-r--r--test/test_helper.rb12
-rw-r--r--test/unit/lib/redmine/hook_test.rb2
-rw-r--r--test/unit/mail_handler_test.rb4
3 files changed, 11 insertions, 7 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index a02f70f6b..2b80c851e 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -164,20 +164,24 @@ class ActiveSupport::TestCase
def assert_mail_body_match(expected, mail)
if expected.is_a?(String)
- assert_include expected, mail.body
+ assert_include expected, mail_body(mail)
else
- assert_match expected, mail.body
+ assert_match expected, mail_body(mail)
end
end
def assert_mail_body_no_match(expected, mail)
if expected.is_a?(String)
- assert_not_include expected, mail.body
+ assert_not_include expected, mail_body(mail)
else
- assert_no_match expected, mail.body
+ assert_no_match expected, mail_body(mail)
end
end
+ def mail_body(mail)
+ mail.body
+ end
+
# Shoulda macros
def self.should_render_404
should_respond_with :not_found
diff --git a/test/unit/lib/redmine/hook_test.rb b/test/unit/lib/redmine/hook_test.rb
index 14782683a..1b0034c95 100644
--- a/test/unit/lib/redmine/hook_test.rb
+++ b/test/unit/lib/redmine/hook_test.rb
@@ -158,7 +158,7 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
Mailer.deliver_issue_add(issue)
mail2 = ActionMailer::Base.deliveries.last
- assert_equal mail.body, mail2.body
+ assert_equal mail_body(mail), mail_body(mail2)
end
def hook_helper
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 218625f74..bf38048db 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -272,8 +272,8 @@ class MailHandlerTest < ActiveSupport::TestCase
email = ActionMailer::Base.deliveries.first
assert_not_nil email
assert email.subject.include?('account activation')
- login = email.body.match(/\* Login: (.*)$/)[1]
- password = email.body.match(/\* Password: (.*)$/)[1]
+ login = mail_body(email).match(/\* Login: (.*)$/)[1]
+ password = mail_body(email).match(/\* Password: (.*)$/)[1]
assert_equal issue.author, User.try_to_login(login, password)
end
end