From 0f6c86ff40d0b0efe672ae76f2b5b536feaf7255 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 17 Dec 2007 00:39:19 +0000 Subject: Added delete_via_redirect and put_via_redirect to integration testing (closes #10497) [philodespotos] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8429 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/integration_test.rb | 43 +++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 771e243b00..4213bb4afa 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -49,28 +49,49 @@ class SessionTest < Test::Unit::TestCase assert_equal 200, @session.follow_redirect! end - def test_get_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - - @session.expects(:get).with(path,args,headers) + def test_request_via_redirect_uses_given_method + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} + @session.expects(:put).with(path, args, headers) + @session.stubs(:redirect?).returns(false) + @session.request_via_redirect(:put, path, args, headers) + end + def test_request_via_redirect_follows_redirects + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} @session.stubs(:redirect?).returns(true, true, false) @session.expects(:follow_redirect!).times(2) + @session.request_via_redirect(:get, path, args, headers) + end + def test_request_via_redirect_returns_status + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} + @session.stubs(:redirect?).returns(false) @session.stubs(:status).returns(200) - assert_equal 200, @session.get_via_redirect(path, args, headers) + assert_equal 200, @session.request_via_redirect(:get, path, args, headers) end - def test_post_via_redirect + def test_get_via_redirect path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } + @session.expects(:request_via_redirect).with(:get, path, args, headers) + @session.get_via_redirect(path, args, headers) + end - @session.expects(:post).with(path,args,headers) + def test_post_via_redirect + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } + @session.expects(:request_via_redirect).with(:post, path, args, headers) + @session.post_via_redirect(path, args, headers) + end - @session.stubs(:redirect?).returns(true, true, false) - @session.expects(:follow_redirect!).times(2) + def test_put_via_redirect + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } + @session.expects(:request_via_redirect).with(:put, path, args, headers) + @session.put_via_redirect(path, args, headers) + end - @session.stubs(:status).returns(200) - assert_equal 200, @session.post_via_redirect(path, args, headers) + def test_delete_via_redirect + path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } + @session.expects(:request_via_redirect).with(:delete, path, args, headers) + @session.delete_via_redirect(path, args, headers) end def test_url_for_with_controller -- cgit v1.2.3