Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8536

Show
Ignore:
Timestamp:
01/03/08 00:40:28 (1 year ago)
Author:
david
Message:

Fixed that you don't have to call super in ActionMailer::TestCase#setup (closes #10406) [jamesgolick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/CHANGELOG

    r8419 r8536  
     1*SVN* 
     2 
     3* Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick] 
     4 
     5 
    16*2.0.2* (December 16th, 2007) 
    27 
  • trunk/actionmailer/lib/action_mailer/test_case.rb

    r8173 r8536  
    3434    end 
    3535 
    36     def setup 
     36    def setup_with_mailer 
    3737      ActionMailer::Base.delivery_method = :test 
    3838      ActionMailer::Base.perform_deliveries = true 
     
    4242      @expected.set_content_type "text", "plain", { "charset" => charset } 
    4343      @expected.mime_version = '1.0' 
     44    end 
     45    alias_method :setup, :setup_with_mailer 
     46 
     47    def self.method_added(method) 
     48      if method.to_s == 'setup' 
     49        unless method_defined?(:setup_without_mailer) 
     50          alias_method :setup_without_mailer, :setup 
     51          define_method(:setup) do 
     52            setup_with_mailer 
     53            setup_without_mailer 
     54          end 
     55        end 
     56      end 
    4457    end 
    4558 
  • trunk/actionmailer/test/test_helper_test.rb

    r8022 r8536  
    116116  end 
    117117end 
     118 
     119class AnotherTestHelperMailerTest < ActionMailer::TestCase 
     120 
     121  tests TestHelperMailer 
     122 
     123  def setup 
     124    # Should not override ActionMailer setup methods 
     125    @test_var = "a value" 
     126  end 
     127 
     128  def test_should_still_setup_mailer 
     129    assert @expected.is_a?(TMail::Mail) 
     130  end 
     131   
     132  def test_should_run_overridden_setup_method 
     133    assert @test_var 
     134  end 
     135end