diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 2 | ||||
-rw-r--r-- | actionmailer/test/asset_host_test.rb (renamed from actionmailer/test/old_base/asset_host_test.rb) | 6 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/mail_layout_test.rb (renamed from actionmailer/test/old_base/mail_layout_test.rb) | 53 | ||||
-rw-r--r-- | actionmailer/test/mailers/base_mailer.rb | 2 | ||||
-rw-r--r-- | actionmailer/test/old_base/adv_attr_test.rb | 5 | ||||
-rw-r--r-- | actionmailer/test/old_base/mail_render_test.rb | 41 | ||||
-rw-r--r-- | actionmailer/test/old_base/mail_service_test.rb | 112 | ||||
-rw-r--r-- | actionmailer/test/test_helper_test.rb | 7 | ||||
-rw-r--r-- | actionmailer/test/url_test.rb (renamed from actionmailer/test/old_base/url_test.rb) | 9 |
10 files changed, 41 insertions, 199 deletions
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index b430dffdf8..0dce0ac15d 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -78,3 +78,5 @@ end def restore_delivery_method ActionMailer::Base.delivery_method = @old_delivery_method end + +ActiveSupport::Deprecation.silenced = true
\ No newline at end of file diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/asset_host_test.rb index cc13c8a4d7..069860ff06 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/asset_host_test.rb @@ -3,9 +3,9 @@ require 'action_controller' class AssetHostMailer < ActionMailer::Base def email_with_asset - recipients 'test@localhost' - subject "testing email containing asset path while asset_host is set" - from "tester@example.com" + mail :to => 'test@localhost', + :subject => 'testing email containing asset path while asset_host is set', + :from => 'tester@example.com' end end diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index c11081072d..7ed9d4a5c0 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -7,9 +7,6 @@ require 'mailers/proc_mailer' require 'mailers/asset_mailer' class BaseTest < ActiveSupport::TestCase - # TODO Add some tests for implicity layout render and url helpers - # so we can get rid of old base tests altogether with old base. - def teardown ActionMailer::Base.asset_host = nil ActionMailer::Base.assets_dir = nil diff --git a/actionmailer/test/old_base/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index 2c2daa0f28..def8da81b8 100644 --- a/actionmailer/test/old_base/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -1,53 +1,45 @@ require 'abstract_unit' class AutoLayoutMailer < ActionMailer::Base + default :to => 'test@localhost', + :subject => "You have a mail", + :from => "tester@example.com" def hello - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" + mail() end def spam - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" - @world = "Earth" - body render(:inline => "Hello, <%= @world %>", :layout => 'spam') + mail(:body => render(:inline => "Hello, <%= @world %>", :layout => 'spam')) end def nolayout - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" - @world = "Earth" - body render(:inline => "Hello, <%= @world %>", :layout => false) + mail(:body => render(:inline => "Hello, <%= @world %>", :layout => false)) end def multipart(type = nil) - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" - - content_type(type) if type + mail(:content_type => type) do |format| + format.text { render } + format.html { render } + end end end class ExplicitLayoutMailer < ActionMailer::Base layout 'spam', :except => [:logout] + default :to => 'test@localhost', + :subject => "You have a mail", + :from => "tester@example.com" + def signup - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" + mail() end def logout - recipients 'test@localhost' - subject "You have a mail" - from "tester@example.com" + mail() end end @@ -91,19 +83,6 @@ class LayoutMailerTest < Test::Unit::TestCase assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end - def test_should_fix_multipart_layout - mail = AutoLayoutMailer.multipart("text/plain") - assert_equal "multipart/alternative", mail.mime_type - assert_equal 2, mail.parts.size - - assert_equal 'text/plain', mail.parts.first.mime_type - assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s - - assert_equal 'text/html', mail.parts.last.mime_type - assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s - end - - def test_should_pickup_layout_given_to_render mail = AutoLayoutMailer.spam assert_equal "Spammer layout Hello, Earth", mail.body.to_s.strip diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb index e89a5820cc..9416bc718e 100644 --- a/actionmailer/test/mailers/base_mailer.rb +++ b/actionmailer/test/mailers/base_mailer.rb @@ -113,6 +113,6 @@ class BaseMailer < ActionMailer::Base end def email_with_translations - body render("email_with_translations.html") + mail :body => render("email_with_translations.html") end end diff --git a/actionmailer/test/old_base/adv_attr_test.rb b/actionmailer/test/old_base/adv_attr_test.rb index f22d733bc5..c5a6b6d88b 100644 --- a/actionmailer/test/old_base/adv_attr_test.rb +++ b/actionmailer/test/old_base/adv_attr_test.rb @@ -11,9 +11,14 @@ class AdvAttrTest < ActiveSupport::TestCase end def setup + ActiveSupport::Deprecation.silenced = true @person = Person.new end + def teardown + ActiveSupport::Deprecation.silenced = false + end + def test_adv_attr assert_nil @person.name @person.name 'Bob' diff --git a/actionmailer/test/old_base/mail_render_test.rb b/actionmailer/test/old_base/mail_render_test.rb index bf489e77d4..3a1d3184f4 100644 --- a/actionmailer/test/old_base/mail_render_test.rb +++ b/actionmailer/test/old_base/mail_render_test.rb @@ -19,18 +19,6 @@ class RenderMailer < ActionMailer::Base body render(:file => "templates/signed_up") end - def rxml_template - recipients 'test@localhost' - subject "rendering rxml template" - from "tester@example.com" - end - - def included_subtemplate - recipients 'test@localhost' - subject "Including another template in the one being rendered" - from "tester@example.com" - end - def no_instance_variable recipients 'test@localhost' subject "No Instance Variable" @@ -41,11 +29,6 @@ class RenderMailer < ActionMailer::Base end end - def initialize_defaults(method_name) - super - mailer_name "test_mailer" - end - def multipart_alternative recipients 'test@localhost' subject 'multipart/alternative' @@ -97,11 +80,13 @@ class RenderHelperTest < Test::Unit::TestCase set_delivery_method :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries.clear + ActiveSupport::Deprecation.silenced = true @recipient = 'test@localhost' end def teardown + ActiveSupport::Deprecation.silenced = false restore_delivery_method end @@ -115,35 +100,16 @@ class RenderHelperTest < Test::Unit::TestCase assert_equal "Hello there,\n\nMr. test@localhost", mail.body.to_s.strip end - def test_rxml_template - mail = RenderMailer.rxml_template.deliver - assert_equal %(<?xml version="1.0" encoding="UTF-8"?>\n<test/>), mail.body.to_s.strip - end - - def test_included_subtemplate - mail = RenderMailer.included_subtemplate.deliver - assert_equal "Hey Ho, let's go!", mail.body.to_s.strip - end - def test_no_instance_variable mail = RenderMailer.no_instance_variable.deliver assert_equal "Look, subject.nil? is true!", mail.body.to_s.strip end - - def test_legacy_multipart_alternative - mail = RenderMailer.multipart_alternative.deliver - assert_equal(2, mail.parts.size) - assert_equal("multipart/alternative", mail.mime_type) - assert_equal("text/plain", mail.parts[0].mime_type) - assert_equal("foo: bar", mail.parts[0].body.encoded) - assert_equal("text/html", mail.parts[1].mime_type) - assert_equal("<strong>foo</strong> bar", mail.parts[1].body.encoded) - end end class FirstSecondHelperTest < Test::Unit::TestCase def setup set_delivery_method :test + ActiveSupport::Deprecation.silenced = true ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries.clear @@ -151,6 +117,7 @@ class FirstSecondHelperTest < Test::Unit::TestCase end def teardown + ActiveSupport::Deprecation.silenced = false restore_delivery_method end diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index a216b94a55..93921978b6 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -334,6 +334,7 @@ class ActionMailerTest < Test::Unit::TestCase ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.deliveries.clear + ActiveSupport::Deprecation.silenced = true @original_logger = TestMailer.logger @recipient = 'test@localhost' @@ -343,6 +344,7 @@ class ActionMailerTest < Test::Unit::TestCase def teardown TestMailer.logger = @original_logger + ActiveSupport::Deprecation.silenced = false restore_delivery_method end @@ -1095,112 +1097,4 @@ EOF ensure TestMailer.smtp_settings.merge!(:enable_starttls_auto => true) end -end - -class InheritableTemplateRootTest < ActiveSupport::TestCase - def test_attr - expected = File.expand_path("#{File.dirname(__FILE__)}/../fixtures/path.with.dots") - assert_equal expected, FunkyPathMailer.template_root.to_s - - sub = Class.new(FunkyPathMailer) - assert_deprecated do - sub.template_root = 'test/path' - end - - assert_equal File.expand_path('test/path'), sub.template_root.to_s - assert_equal expected, FunkyPathMailer.template_root.to_s - end -end - -class MethodNamingTest < ActiveSupport::TestCase - include ActionMailer::TestHelper - - class TestMailer < ActionMailer::Base - def send - body 'foo' - end - end - - def setup - set_delivery_method :test - ActionMailer::Base.perform_deliveries = true - ActionMailer::Base.deliveries.clear - end - - def teardown - restore_delivery_method - end - - def test_send_method - assert_nothing_raised do - assert_emails 1 do - assert_deprecated do - TestMailer.deliver_send - end - end - end - end -end -class RespondToTest < Test::Unit::TestCase - class RespondToMailer < ActionMailer::Base; end - - def setup - set_delivery_method :test - end - - def teardown - restore_delivery_method - end - - def test_should_respond_to_new - assert_respond_to RespondToMailer, :new - end - - def test_should_respond_to_create_with_template_suffix - assert_respond_to RespondToMailer, :create_any_old_template - end - - def test_should_respond_to_deliver_with_template_suffix - assert_respond_to RespondToMailer, :deliver_any_old_template - end - - def test_should_not_respond_to_new_with_template_suffix - assert !RespondToMailer.respond_to?(:new_any_old_template) - end - - def test_should_not_respond_to_create_with_template_suffix_unless_it_is_separated_by_an_underscore - assert !RespondToMailer.respond_to?(:createany_old_template) - end - - def test_should_not_respond_to_deliver_with_template_suffix_unless_it_is_separated_by_an_underscore - assert !RespondToMailer.respond_to?(:deliverany_old_template) - end - - def test_should_not_respond_to_create_with_template_suffix_if_it_begins_with_a_uppercase_letter - assert !RespondToMailer.respond_to?(:create_Any_old_template) - end - - def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_uppercase_letter - assert !RespondToMailer.respond_to?(:deliver_Any_old_template) - end - - def test_should_not_respond_to_create_with_template_suffix_if_it_begins_with_a_digit - assert !RespondToMailer.respond_to?(:create_1_template) - end - - def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_digit - assert !RespondToMailer.respond_to?(:deliver_1_template) - end - - def test_should_not_respond_to_method_where_deliver_is_not_a_suffix - assert !RespondToMailer.respond_to?(:foo_deliver_template) - end - - def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method - error = assert_raise NoMethodError do - RespondToMailer.not_a_method - end - - assert_match(/method.*not_a_method/, error.message) - end -end +end
\ No newline at end of file diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 5a101e852f..dd62164176 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -2,11 +2,10 @@ require 'abstract_unit' class TestHelperMailer < ActionMailer::Base def test - recipients "test@example.com" - from "tester@example.com" - @world = "Earth" - render(:inline => "Hello, <%= @world %>") + mail :body => render(:inline => "Hello, <%= @world %>"), + :to => "test@example.com", + :from => "tester@example.com" end end diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/url_test.rb index 573186dbee..9b2b38d9e8 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -18,13 +18,10 @@ class UrlTestMailer < ActionMailer::Base end def signed_up_with_url(recipient) - @recipients = recipient - @subject = "[Signed up] Welcome #{recipient}" - @from = "system@loudthinking.com" - @sent_on = Time.local(2004, 12, 12) - @recipient = recipient @welcome_url = url_for :host => "example.com", :controller => "welcome", :action => "greeting" + mail(:to => recipient, :subject => "[Signed up] Welcome #{recipient}", + :from => "system@loudthinking.com", :date => Time.local(2004, 12, 12)) end end @@ -47,6 +44,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase set_delivery_method :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries.clear + ActiveSupport::Deprecation.silenced = false @recipient = 'test@localhost' end @@ -71,6 +69,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase expected.body = "Hello there,\n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />" expected.from = "system@loudthinking.com" expected.date = Time.local(2004, 12, 12) + expected.content_type = "text/html" created = nil assert_nothing_raised { created = UrlTestMailer.signed_up_with_url(@recipient) } |