aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-01-20 10:34:17 +0100
committerXavier Noria <fxn@hashref.com>2011-01-20 10:34:17 +0100
commit02319b7982fa7e55aecf79ede8bf0cb6961e0206 (patch)
tree2b63c0e0398ec79d042d72864092000181dc3e7e /actionmailer
parent236f1f52cdcb695ee42ec1ad384fc9bee643f435 (diff)
parentbc9b1075aec2a63f789b105cd11886a2c8c45ccf (diff)
downloadrails-02319b7982fa7e55aecf79ede8bf0cb6961e0206.tar.gz
rails-02319b7982fa7e55aecf79ede8bf0cb6961e0206.tar.bz2
rails-02319b7982fa7e55aecf79ede8bf0cb6961e0206.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb4
-rw-r--r--actionmailer/test/i18n_with_controller_test.rb46
2 files changed, 50 insertions, 0 deletions
diff --git a/actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb b/actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb
new file mode 100644
index 0000000000..f5340283f1
--- /dev/null
+++ b/actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb
@@ -0,0 +1,4 @@
+Hello there,
+
+Mr. <%= @recipient %>. Be greeted, new member!
+
diff --git a/actionmailer/test/i18n_with_controller_test.rb b/actionmailer/test/i18n_with_controller_test.rb
new file mode 100644
index 0000000000..7040ae6f8d
--- /dev/null
+++ b/actionmailer/test/i18n_with_controller_test.rb
@@ -0,0 +1,46 @@
+require 'abstract_unit'
+require 'action_controller'
+
+class I18nTestMailer < ActionMailer::Base
+ configure do |c|
+ c.assets_dir = ''
+ end
+
+ def mail_with_i18n_subject(recipient)
+ @recipient = recipient
+ I18n.locale = :de
+ mail(:to => recipient, :subject => "#{I18n.t :email_subject} #{recipient}",
+ :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'
+ end
+end
+
+class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest
+ Routes = ActionDispatch::Routing::RouteSet.new
+ Routes.draw do
+ match ':controller(/:action(/:id))'
+ end
+
+ def app
+ Routes
+ end
+
+ def setup
+ I18n.backend.store_translations('de', :email_subject => '[Signed up] Welcome')
+ end
+
+ def teardown
+ I18n.locale = :en
+ end
+
+ def test_send_mail
+ get '/test/send_mail'
+ assert_equal "Mail sent", @response.body
+ end
+end