diff options
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 43 |
1 files changed, 32 insertions, 11 deletions
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 |