diff options
author | Zuhao Wan <wanzuhao@gmail.com> | 2014-05-13 11:43:26 +0800 |
---|---|---|
committer | Zuhao Wan <wanzuhao@gmail.com> | 2014-05-13 16:38:21 +0800 |
commit | 32ef7d3c5c5901dee4aeda99557e4416819428ce (patch) | |
tree | b50410f783f8bb793db829fb5deb046a93e27199 | |
parent | 84908bbde97ef70b09aca4937793052422bc06ed (diff) | |
download | rails-32ef7d3c5c5901dee4aeda99557e4416819428ce.tar.gz rails-32ef7d3c5c5901dee4aeda99557e4416819428ce.tar.bz2 rails-32ef7d3c5c5901dee4aeda99557e4416819428ce.zip |
Use with_translation helper to clean up I18n stored translations.
-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 |