diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-13 10:43:50 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-13 10:43:50 +0200 |
commit | fd6d6dc6024adb77be92f9ef7d13dbf5722c1770 (patch) | |
tree | e0f426fa6b307de895fecbb300bd847aa1c76adb /actionmailer | |
parent | 9392d1615c14278db32ca3178039175ab7a6579e (diff) | |
parent | 32ef7d3c5c5901dee4aeda99557e4416819428ce (diff) | |
download | rails-fd6d6dc6024adb77be92f9ef7d13dbf5722c1770.tar.gz rails-fd6d6dc6024adb77be92f9ef7d13dbf5722c1770.tar.bz2 rails-fd6d6dc6024adb77be92f9ef7d13dbf5722c1770.zip |
Merge pull request #15083 from zuhao/refactor_actionmailer_i18n_with_controller_test
Use with_translation helper to clean up I18n stored translations.
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/test/i18n_with_controller_test.rb | 25 |
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 |