mirror of
https://github.com/github/rails.git
synced 2026-01-30 08:48:06 -05:00
Integration tests: get_ and post_via_redirect take a headers hash. Closes #9130.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8047 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Integration tests: get_ and post_via_redirect take a headers hash. #9130 [simonjefford]
|
||||
|
||||
* Simplfy #view_paths implementation. ActionView templates get the exact object, not a dup. [Rick]
|
||||
|
||||
* Update tests for ActiveSupport's JSON escaping change. [rick]
|
||||
|
||||
@@ -124,17 +124,18 @@ module ActionController
|
||||
# Performs a GET request, following any subsequent redirect. Note that
|
||||
# the redirects are followed until the response is not a redirect--this
|
||||
# means you may run into an infinite loop if your redirect loops back to
|
||||
# itself.
|
||||
def get_via_redirect(path, args={})
|
||||
get path, args
|
||||
# itself. Headers are treated in the same way as #get.
|
||||
def get_via_redirect(path, args={}, headers = {})
|
||||
get path, args, headers
|
||||
follow_redirect! while redirect?
|
||||
status
|
||||
end
|
||||
|
||||
# Performs a POST request, following any subsequent redirect. This is
|
||||
# vulnerable to infinite loops, the same as #get_via_redirect.
|
||||
def post_via_redirect(path, args={})
|
||||
post path, args
|
||||
# vulnerable to infinite loops, the same as #get_via_redirect. Headers are
|
||||
# treated in the same way as #get.
|
||||
def post_via_redirect(path, args={}, headers = {})
|
||||
post path, args, headers
|
||||
follow_redirect! while redirect?
|
||||
status
|
||||
end
|
||||
|
||||
@@ -50,27 +50,27 @@ class SessionTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_get_via_redirect
|
||||
path = "/somepath"; args = {:id => '1'}
|
||||
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
||||
|
||||
@session.expects(:get).with(path,args)
|
||||
@session.expects(:get).with(path,args,headers)
|
||||
|
||||
@session.stubs(:redirect?).returns(true, true, false)
|
||||
@session.expects(:follow_redirect!).times(2)
|
||||
|
||||
@session.stubs(:status).returns(200)
|
||||
assert_equal 200, @session.get_via_redirect(path, args)
|
||||
assert_equal 200, @session.get_via_redirect(path, args, headers)
|
||||
end
|
||||
|
||||
def test_post_via_redirect
|
||||
path = "/somepath"; args = {:id => '1'}
|
||||
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
||||
|
||||
@session.expects(:post).with(path,args)
|
||||
@session.expects(:post).with(path,args,headers)
|
||||
|
||||
@session.stubs(:redirect?).returns(true, true, false)
|
||||
@session.expects(:follow_redirect!).times(2)
|
||||
|
||||
@session.stubs(:status).returns(200)
|
||||
assert_equal 200, @session.post_via_redirect(path, args)
|
||||
assert_equal 200, @session.post_via_redirect(path, args, headers)
|
||||
end
|
||||
|
||||
def test_url_for_with_controller
|
||||
|
||||
Reference in New Issue
Block a user