From 236fe10fe9fd2ee3138784bf0cd5e4248c6b5d5e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 22 Feb 2007 09:28:10 +0000 Subject: Integration tests: introduce methods for other HTTP methods. Closes #6353. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6203 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/integration.rb | 2 +- actionpack/test/controller/integration_test.rb | 39 ++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index e131ec0f9e..62aaa15c08 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Integration tests: introduce methods for other HTTP methods. #6353 [caboose] + * Routing: better support for escaped values in route segments. #7544 [Chris Roos] diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index c2f1fcf1f9..b6a883d58e 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -490,7 +490,7 @@ module ActionController @integration_session = open_session end - %w(get post cookies assigns xml_http_request).each do |method| + %w(get post put head delete cookies assigns xml_http_request).each do |method| define_method(method) do |*args| reset! unless @integration_session # reset the html_document variable, but only for new get/post calls diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index a26b6eb259..3bea949867 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -9,7 +9,7 @@ uses_mocha 'integration' do module ActionController module Integration class Session - def process + def process(*args) end def generic_url_rewriter @@ -143,6 +143,43 @@ class SessionTest < Test::Unit::TestCase end end +class IntegrationTestTest < Test::Unit::TestCase + + def setup + @test = ::ActionController::IntegrationTest.new(:default_test) + @test.class.stubs(:fixture_table_names).returns([]) + @session = @test.open_session + end + + def test_opens_new_session + @test.class.expects(:fixture_table_names).times(2).returns(['foo']) + + session1 = @test.open_session { |sess| } + session2 = @test.open_session # implicit session + + assert_equal ::ActionController::Integration::Session, session1.class + assert_equal ::ActionController::Integration::Session, session2.class + assert_not_equal session1, session2 + end + +end + +# Tests that integration tests don't call Controller test methods for processing. +# Integration tests have their own setup and teardown. +class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest + + def self.fixture_table_names + [] + end + + def test_integration_methods_called + %w( get post head put delete ).each do |verb| + assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') } + end + end + +end + # TODO # class MockCGITest < Test::Unit::TestCase # end -- cgit v1.2.3