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

Changeset 6203

Show
Ignore:
Timestamp:
02/22/07 09:28:10 (2 years ago)
Author:
bitsweat
Message:

Integration tests: introduce methods for other HTTP methods. Closes #6353.

Files:

Legend:

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

    r6185 r6203  
    11*SVN* 
     2 
     3* Integration tests: introduce methods for other HTTP methods.  #6353 [caboose] 
    24 
    35* Routing: better support for escaped values in route segments.  #7544 [Chris 
  • trunk/actionpack/lib/action_controller/integration.rb

    r6057 r6203  
    491491    end 
    492492 
    493     %w(get post cookies assigns xml_http_request).each do |method| 
     493    %w(get post put head delete cookies assigns xml_http_request).each do |method| 
    494494      define_method(method) do |*args| 
    495495        reset! unless @integration_session 
  • trunk/actionpack/test/controller/integration_test.rb

    r5926 r6203  
    1010  module Integration 
    1111    class Session 
    12       def process 
     12      def process(*args) 
    1313      end 
    1414 
     
    144144end 
    145145 
     146class IntegrationTestTest < Test::Unit::TestCase 
     147 
     148  def setup 
     149    @test = ::ActionController::IntegrationTest.new(:default_test) 
     150    @test.class.stubs(:fixture_table_names).returns([]) 
     151    @session = @test.open_session 
     152  end 
     153   
     154  def test_opens_new_session 
     155    @test.class.expects(:fixture_table_names).times(2).returns(['foo']) 
     156 
     157    session1 = @test.open_session { |sess| } 
     158    session2 = @test.open_session # implicit session 
     159 
     160    assert_equal ::ActionController::Integration::Session, session1.class 
     161    assert_equal ::ActionController::Integration::Session, session2.class 
     162    assert_not_equal session1, session2 
     163  end 
     164 
     165end 
     166 
     167# Tests that integration tests don't call Controller test methods for processing. 
     168# Integration tests have their own setup and teardown. 
     169class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest 
     170 
     171  def self.fixture_table_names 
     172    [] 
     173  end 
     174 
     175  def test_integration_methods_called 
     176    %w( get post head put delete ).each do |verb| 
     177      assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') } 
     178    end 
     179  end 
     180 
     181end 
     182 
    146183# TODO 
    147184# class MockCGITest < Test::Unit::TestCase