Skip to content
This repository
Browse code

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

…6353.  Merges [6203]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7319 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 631bf6b203be4d1d8ab0dac6792117aef2f96f8b 1 parent 6cc01c9
Michael Koziarski authored August 15, 2007
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Integration tests: introduce methods for other HTTP methods.  #6353 [caboose]
  4
+
3 5
 * Improve performance of action caching. Closes #8231 [skaes]
4 6
 
5 7
 * Fix errors with around_filters which do not yield, restore 1.1 behaviour with after filters. Closes #8891 [skaes]
2  actionpack/lib/action_controller/integration.rb
@@ -500,7 +500,7 @@ def reset!
500 500
       @integration_session = open_session
501 501
     end
502 502
 
503  
-    %w(get post cookies assigns xml_http_request).each do |method|
  503
+    %w(get post put head delete cookies assigns xml_http_request).each do |method|
504 504
       define_method(method) do |*args|
505 505
         reset! unless @integration_session
506 506
         # reset the html_document variable, but only for new get/post calls
39  actionpack/test/controller/integration_test.rb
@@ -11,7 +11,7 @@
11 11
 module ActionController
12 12
   module Integration
13 13
     class Session
14  
-      def process
  14
+      def process(*args)
15 15
       end
16 16
 
17 17
       def generic_url_rewriter
@@ -195,6 +195,43 @@ def test_xml_http_request_head
195 195
   end
196 196
 end
197 197
 
  198
+class IntegrationTestTest < Test::Unit::TestCase
  199
+
  200
+  def setup
  201
+    @test = ::ActionController::IntegrationTest.new(:default_test)
  202
+    @test.class.stubs(:fixture_table_names).returns([])
  203
+    @session = @test.open_session
  204
+  end
  205
+  
  206
+  def test_opens_new_session
  207
+    @test.class.expects(:fixture_table_names).times(2).returns(['foo'])
  208
+
  209
+    session1 = @test.open_session { |sess| }
  210
+    session2 = @test.open_session # implicit session
  211
+
  212
+    assert_equal ::ActionController::Integration::Session, session1.class
  213
+    assert_equal ::ActionController::Integration::Session, session2.class
  214
+    assert_not_equal session1, session2
  215
+  end
  216
+
  217
+end
  218
+
  219
+# Tests that integration tests don't call Controller test methods for processing.
  220
+# Integration tests have their own setup and teardown.
  221
+class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
  222
+
  223
+  def self.fixture_table_names
  224
+    []
  225
+  end
  226
+
  227
+  def test_integration_methods_called
  228
+    %w( get post head put delete ).each do |verb|
  229
+      assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') }
  230
+    end
  231
+  end
  232
+
  233
+end
  234
+
198 235
 # TODO
199 236
 # class MockCGITest < Test::Unit::TestCase
200 237
 # end

0 notes on commit 631bf6b

Please sign in to comment.
Something went wrong with that request. Please try again.