diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/asset_host_test.rb | 4 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 6 | ||||
-rw-r--r-- | actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb | 4 | ||||
-rw-r--r-- | actionmailer/test/i18n_with_controller_test.rb | 46 | ||||
-rw-r--r-- | actionmailer/test/old_base/tmail_compat_test.rb | 9 |
6 files changed, 64 insertions, 8 deletions
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 diff --git a/actionmailer/test/asset_host_test.rb b/actionmailer/test/asset_host_test.rb index 069860ff06..b24eca5fbb 100644 --- a/actionmailer/test/asset_host_test.rb +++ b/actionmailer/test/asset_host_test.rb @@ -29,7 +29,7 @@ class AssetHostTest < Test::Unit::TestCase assert_equal %Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}, mail.body.to_s.strip end - def test_asset_host_as_one_arguement_proc + def test_asset_host_as_one_argument_proc AssetHostMailer.config.asset_host = Proc.new { |source| if source.starts_with?('/images') "http://images.example.com" @@ -41,7 +41,7 @@ class AssetHostTest < Test::Unit::TestCase assert_equal %Q{<img alt="Somelogo" src="http://images.example.com/images/somelogo.png" />}, mail.body.to_s.strip end - def test_asset_host_as_two_arguement_proc + def test_asset_host_as_two_argument_proc ActionController::Base.config.asset_host = Proc.new {|source,request| if request && request.ssl? "https://www.example.com" diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 7ed9d4a5c0..1b793d255e 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -32,21 +32,21 @@ class BaseTest < ActiveSupport::TestCase end test "mail() with bcc, cc, content_type, charset, mime_version, reply_to and date" do - @time = Time.now.beginning_of_day.to_datetime + time = Time.now.beginning_of_day.to_datetime email = BaseMailer.welcome(:bcc => 'bcc@test.lindsaar.net', :cc => 'cc@test.lindsaar.net', :content_type => 'multipart/mixed', :charset => 'iso-8559-1', :mime_version => '2.0', :reply_to => 'reply-to@test.lindsaar.net', - :date => @time) + :date => time) assert_equal(['bcc@test.lindsaar.net'], email.bcc) assert_equal(['cc@test.lindsaar.net'], email.cc) assert_equal('multipart/mixed; charset=iso-8559-1', email.content_type) assert_equal('iso-8559-1', email.charset) assert_equal('2.0', email.mime_version) assert_equal(['reply-to@test.lindsaar.net'], email.reply_to) - assert_equal(@time, email.date) + assert_equal(time, email.date) end test "mail() renders the template using the method being processed" do 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 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 |