diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG | 5 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/test_case.rb | 15 | ||||
-rw-r--r-- | actionmailer/test/test_helper_test.rb | 18 |
3 files changed, 37 insertions, 1 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 8ba3ccdea6..892ec71ed1 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,3 +1,8 @@ +*SVN* + +* Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick] + + *2.0.2* (December 16th, 2007) * Included in Rails 2.0.2 diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index cc75b39280..7829baa799 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -33,7 +33,7 @@ module ActionMailer end end - def setup + def setup_with_mailer ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] @@ -42,6 +42,19 @@ module ActionMailer @expected.set_content_type "text", "plain", { "charset" => charset } @expected.mime_version = '1.0' end + alias_method :setup, :setup_with_mailer + + def self.method_added(method) + if method.to_s == 'setup' + unless method_defined?(:setup_without_mailer) + alias_method :setup_without_mailer, :setup + define_method(:setup) do + setup_with_mailer + setup_without_mailer + end + end + end + end private def charset diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index eb17e3e803..d361e23a8e 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -115,3 +115,21 @@ class TestHelperMailerTest < ActionMailer::TestCase assert_match /0 .* but 1/, error.message end end + +class AnotherTestHelperMailerTest < ActionMailer::TestCase + + tests TestHelperMailer + + def setup + # Should not override ActionMailer setup methods + @test_var = "a value" + end + + def test_should_still_setup_mailer + assert @expected.is_a?(TMail::Mail) + end + + def test_should_run_overridden_setup_method + assert @test_var + end +end |