From d1c957d06744e468c56274e047460e596ef61d73 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 21 May 2007 09:15:16 +0000 Subject: Integration tests: alias xhr to xml_http_request and add a request_method argument instead of always using POST. Closes #7124. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6796 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/integration_test.rb | 58 ++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 3bea949867..7ef7865df4 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -132,14 +132,64 @@ class SessionTest < Test::Unit::TestCase @session.head(path,params,headers) end - def test_xml_http_request + def test_xml_http_request_deprecated_call path = "/index"; params = "blah"; headers = {:location => 'blah'} headers_after_xhr = headers.merge( "X-Requested-With" => "XMLHttpRequest", "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" ) - @session.expects(:post).with(path,params,headers_after_xhr) - @session.xml_http_request(path,params,headers) + @session.expects(:process).with(:post,path,params,headers_after_xhr) + assert_deprecated { @session.xml_http_request(path,params,headers) } + end + + def test_xml_http_request_get + path = "/index"; params = "blah"; headers = {:location => 'blah'} + headers_after_xhr = headers.merge( + "X-Requested-With" => "XMLHttpRequest", + "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" + ) + @session.expects(:process).with(:get,path,params,headers_after_xhr) + @session.xml_http_request(:get,path,params,headers) + end + + def test_xml_http_request_post + path = "/index"; params = "blah"; headers = {:location => 'blah'} + headers_after_xhr = headers.merge( + "X-Requested-With" => "XMLHttpRequest", + "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" + ) + @session.expects(:process).with(:post,path,params,headers_after_xhr) + @session.xml_http_request(:post,path,params,headers) + end + + def test_xml_http_request_put + path = "/index"; params = "blah"; headers = {:location => 'blah'} + headers_after_xhr = headers.merge( + "X-Requested-With" => "XMLHttpRequest", + "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" + ) + @session.expects(:process).with(:put,path,params,headers_after_xhr) + @session.xml_http_request(:put,path,params,headers) + end + + def test_xml_http_request_delete + path = "/index"; params = "blah"; headers = {:location => 'blah'} + headers_after_xhr = headers.merge( + "X-Requested-With" => "XMLHttpRequest", + "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" + ) + @session.expects(:process).with(:delete,path,params,headers_after_xhr) + @session.xml_http_request(:delete,path,params,headers) + end + + def test_xml_http_request_head + path = "/index"; params = "blah"; headers = {:location => 'blah'} + headers_after_xhr = headers.merge( + "X-Requested-With" => "XMLHttpRequest", + "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" + ) + @session.expects(:process).with(:head,path,params,headers_after_xhr) + @session.xml_http_request(:head,path,params,headers) end end @@ -150,7 +200,7 @@ class IntegrationTestTest < Test::Unit::TestCase @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']) -- cgit v1.2.3