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

Changeset 8497

Show
Ignore:
Timestamp:
12/28/07 05:21:24 (6 months ago)
Author:
bitsweat
Message:

Ensure that test case setup is run even if overridden. Closes #10382.

Files:

Legend:

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

    r8485 r8497  
    11*SVN* 
     2 
     3* Ensure that test case setup is run even if overridden.  #10382 [Josh Peek] 
    24 
    35* Fix HTML Sanitizer to allow trailing spaces in CSS style attributes.  Closes #10566 [wesley.moxam] 
  • trunk/actionpack/lib/action_controller/test_case.rb

    r8283 r8497  
    4545    end 
    4646 
    47     def setup 
     47    def setup_with_controller 
    4848      @controller = self.class.controller_class.new 
    4949      @request    = TestRequest.new 
    5050      @response   = TestResponse.new 
    5151    end 
    52   end 
     52    alias_method :setup, :setup_with_controller 
     53 
     54    def self.method_added(method) 
     55      if method.to_s == 'setup' 
     56        unless method_defined?(:setup_without_controller) 
     57          alias_method :setup_without_controller, :setup 
     58          define_method(:setup) do 
     59            setup_with_controller 
     60            setup_without_controller 
     61          end 
     62        end 
     63      end 
     64    end 
     65 end 
    5366end 
  • trunk/actionpack/test/controller/test_test.rb

    r8318 r8497  
    615615end 
    616616 
     617class ContentControllerTest < ActionController::TestCase 
     618  def setup 
     619    # Should not override ActionController setup methods 
     620  end 
     621 
     622  def test_should_still_setup_controller 
     623    assert_kind_of(ContentController, @controller) 
     624  end 
     625end 
     626 
    617627class CrazyNameTest < ActionController::TestCase 
    618628  tests ContentController 
     
    621631  end 
    622632end 
    623