aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/i18n_with_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/test/i18n_with_controller_test.rb')
-rw-r--r--actionmailer/test/i18n_with_controller_test.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/actionmailer/test/i18n_with_controller_test.rb b/actionmailer/test/i18n_with_controller_test.rb
index 14a1b11b6d..d502d42ffd 100644
--- a/actionmailer/test/i18n_with_controller_test.rb
+++ b/actionmailer/test/i18n_with_controller_test.rb
@@ -10,15 +10,15 @@ class I18nTestMailer < ActionMailer::Base
def mail_with_i18n_subject(recipient)
@recipient = recipient
I18n.locale = :de
- mail(to: recipient, subject: "#{I18n.t :email_subject} #{recipient}",
+ mail(to: recipient, subject: I18n.t(:email_subject),
from: "system@loudthinking.com", date: Time.local(2004, 12, 12))
end
end
class TestController < ActionController::Base
def send_mail
- I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver
- render text: 'Mail sent'
+ email = I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver
+ render text: "Mail sent - Subject: #{email.subject}"
end
end
@@ -32,16 +32,19 @@ class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest
Routes
end
- def setup
- I18n.backend.store_translations('de', email_subject: '[Signed up] Welcome')
+ def test_send_mail
+ with_translation 'de', email_subject: '[Anmeldung] Willkommen' do
+ get '/test/send_mail'
+ assert_equal "Mail sent - Subject: [Anmeldung] Willkommen", @response.body
+ end
end
- def teardown
- I18n.locale = :en
- end
+ protected
- def test_send_mail
- get '/test/send_mail'
- assert_equal "Mail sent", @response.body
+ def with_translation(locale, data)
+ I18n.backend.store_translations(locale, data)
+ yield
+ ensure
+ I18n.backend.reload!
end
end