aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorFrank Fischer <frankf@intertech.de>2011-01-14 09:32:51 +0100
committerJosé Valim <jose.valim@gmail.com>2011-01-19 23:24:57 +0100
commitb247f3944282fb22c68fd4f9248a16fcda63b186 (patch)
treef1fa0b114468d9af95a6257e96a426cd97a00d74 /actionmailer/test
parent16a23a184e8b091392c0b6001a025bee8323ec8e (diff)
downloadrails-b247f3944282fb22c68fd4f9248a16fcda63b186.tar.gz
rails-b247f3944282fb22c68fd4f9248a16fcda63b186.tar.bz2
rails-b247f3944282fb22c68fd4f9248a16fcda63b186.zip
Added a testcase for bug [#5329]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb4
-rw-r--r--actionmailer/test/i18n_with_controller_test.rb50
2 files changed, 54 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..759c007c45
--- /dev/null
+++ b/actionmailer/test/i18n_with_controller_test.rb
@@ -0,0 +1,50 @@
+require 'abstract_unit'
+require 'action_controller'
+
+class I18nTestMailer < ActionMailer::Base
+
+ configure do |c|
+ c.assets_dir = '' # To get the tests to pass
+ 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(@recipient).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')
+ set_delivery_method :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries.clear
+ ActiveSupport::Deprecation.silenced = false
+
+ @recipient = 'test@localhost'
+ end
+
+ def test_send_mail
+ get '/test/send_mail'
+ assert_equal "Mail sent", @response.body
+ end
+end