From c76c699f301678f86054b1019fa1ca78c46df47b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 12 Jan 2011 15:28:57 -0800 Subject: turn off deprecation silencing --- actionmailer/test/old_base/tmail_compat_test.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/old_base/tmail_compat_test.rb b/actionmailer/test/old_base/tmail_compat_test.rb index 23706e99ff..51558c2bfa 100644 --- a/actionmailer/test/old_base/tmail_compat_test.rb +++ b/actionmailer/test/old_base/tmail_compat_test.rb @@ -1,6 +1,14 @@ require 'abstract_unit' class TmailCompatTest < ActiveSupport::TestCase + def setup + @silence = ActiveSupport::Deprecation.silenced + ActiveSupport::Deprecation.silenced = false + end + + def teardown + ActiveSupport::Deprecation.silenced = @silence + end def test_set_content_type_raises_deprecation_warning mail = Mail.new @@ -31,5 +39,4 @@ class TmailCompatTest < ActiveSupport::TestCase end assert_equal mail.content_transfer_encoding, "base64" end - end -- cgit v1.2.3 From b247f3944282fb22c68fd4f9248a16fcda63b186 Mon Sep 17 00:00:00 2001 From: Frank Fischer Date: Fri, 14 Jan 2011 09:32:51 +0100 Subject: Added a testcase for bug [#5329] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../i18n_test_mailer/mail_with_i18n_subject.erb | 4 ++ actionmailer/test/i18n_with_controller_test.rb | 50 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb create mode 100644 actionmailer/test/i18n_with_controller_test.rb (limited to 'actionmailer/test') 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 -- cgit v1.2.3 From 262b2ea8cda20999ddf8c4bf13b7a70453e996d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 19 Jan 2011 23:42:10 +0100 Subject: Solve SystemStackError when changing locale inside ActionMailer [#5329 state:resolved] --- actionmailer/test/i18n_with_controller_test.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/i18n_with_controller_test.rb b/actionmailer/test/i18n_with_controller_test.rb index 759c007c45..7040ae6f8d 100644 --- a/actionmailer/test/i18n_with_controller_test.rb +++ b/actionmailer/test/i18n_with_controller_test.rb @@ -2,13 +2,12 @@ require 'abstract_unit' require 'action_controller' class I18nTestMailer < ActionMailer::Base - configure do |c| - c.assets_dir = '' # To get the tests to pass + c.assets_dir = '' end def mail_with_i18n_subject(recipient) - @recipient = 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)) @@ -17,13 +16,12 @@ end class TestController < ActionController::Base def send_mail - I18nTestMailer.mail_with_i18n_subject(@recipient).deliver + 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))' @@ -35,12 +33,10 @@ class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest 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 + end - @recipient = 'test@localhost' + def teardown + I18n.locale = :en end def test_send_mail -- cgit v1.2.3 From 4083e0ea2ae6f87929a32935122f2427845098e0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 9 Feb 2011 10:11:29 -0800 Subject: removing text-format in favor of a more simple solution --- actionmailer/test/abstract_unit.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 0dce0ac15d..ce664bf301 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -25,7 +25,6 @@ end silence_warnings do # These external dependencies have warnings :/ - require 'text/format' require 'mail' end @@ -79,4 +78,4 @@ def restore_delivery_method ActionMailer::Base.delivery_method = @old_delivery_method end -ActiveSupport::Deprecation.silenced = true \ No newline at end of file +ActiveSupport::Deprecation.silenced = true -- cgit v1.2.3