Fixed test: calling Mail::Body#encoded to get a String (Rails 3)

From Rails' CHANGELOG
… Mail.body returns a Mail::Body class object, need to call #encoded or #decoded to get the string you want.

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Andreas Haller 2010-03-21 04:37:38 +01:00 committed by José Valim
parent e136573905
commit 5c19605d6f
3 changed files with 8 additions and 8 deletions

View File

@ -48,13 +48,13 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
end
test 'body should have user info' do
assert_match /#{user.email}/, mail.body
assert_match /#{user.email}/, mail.body.encoded
end
test 'body should have link to confirm the account' do
host = ActionMailer::Base.default_url_options[:host]
confirmation_url_regexp = %r{<a href=\"http://#{host}/users/confirmation\?confirmation_token=#{user.confirmation_token}">}
assert_match confirmation_url_regexp, mail.body
assert_match confirmation_url_regexp, mail.body.encoded
end
test 'renders a scoped if scoped_views is set to true' do
@ -73,7 +73,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
end
test 'mailer sender accepts a proc' do
swap Devise, :mailer_sender => lambda { "another@example.com" } do
swap Devise, :mailer_sender => proc { "another@example.com" } do
assert_equal ['another@example.com'], mail.from
end
end

View File

@ -51,17 +51,17 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
end
test 'body should have user info' do
assert_match /#{user.email}/, mail.body
assert_match(/#{user.email}/, mail.body.encoded)
end
test 'body should have link to confirm the account' do
host = ActionMailer::Base.default_url_options[:host]
reset_url_regexp = %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=#{user.reset_password_token}">}
assert_match reset_url_regexp, mail.body
assert_match reset_url_regexp, mail.body.encoded
end
test 'mailer sender accepts a proc' do
swap Devise, :mailer_sender => lambda { "another@example.com" } do
swap Devise, :mailer_sender => proc { "another@example.com" } do
assert_equal ['another@example.com'], mail.from
end
end

View File

@ -51,12 +51,12 @@ class UnlockInstructionsTest < ActionMailer::TestCase
end
test 'body should have user info' do
assert_match /#{user.email}/, mail.body
assert_match(/#{user.email}/, mail.body.encoded)
end
test 'body should have link to unlock the account' do
host = ActionMailer::Base.default_url_options[:host]
unlock_url_regexp = %r{<a href=\"http://#{host}/users/unlock\?unlock_token=#{user.unlock_token}">}
assert_match unlock_url_regexp, mail.body
assert_match unlock_url_regexp, mail.body.encoded
end
end