aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-21 09:15:16 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-21 09:15:16 +0000
commitd1c957d06744e468c56274e047460e596ef61d73 (patch)
treebe6597d3966ad1d297cb9a71d8affa2c793b8176 /actionpack/test
parent7232cb705ac21795374eeb05fab5fa2437efaabb (diff)
downloadrails-d1c957d06744e468c56274e047460e596ef61d73.tar.gz
rails-d1c957d06744e468c56274e047460e596ef61d73.tar.bz2
rails-d1c957d06744e468c56274e047460e596ef61d73.zip
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
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/integration_test.rb58
1 files changed, 54 insertions, 4 deletions
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'])