Changeset 8429
- Timestamp:
- 12/17/07 00:39:19 (9 months ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/integration.rb (modified) (1 diff)
- trunk/actionpack/test/controller/integration_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8426 r8429 1 1 *2.0.2* (December 16th, 2007) 2 3 * Added delete_via_redirect and put_via_redirect to integration testing #10497 [philodespotos] 2 4 3 5 * Allow headers['Accept'] to be set by hand when calling xml_http_request #10461 [BMorearty] trunk/actionpack/lib/action_controller/integration.rb
r8426 r8429 122 122 end 123 123 124 # Performs a GET request, following any subsequent redirect. Note that125 # the redirects are followed until the response is not a redirect--this126 # means you may run into an infinite loop if your redirect loops back to127 # itself. Headers are treated in the same way as #get.128 def get_via_redirect(path, args={}, headers = {})129 get path, args, headers124 # Performs a request using the specified method, following any subsequent 125 # redirect. Note that the redirects are followed until the response is 126 # not a redirect--this means you may run into an infinite loop if your 127 # redirect loops back to itself. 128 def request_via_redirect(http_method, path, parameters = nil, headers = nil) 129 send(http_method, path, parameters, headers) 130 130 follow_redirect! while redirect? 131 131 status 132 132 end 133 133 134 # Performs a POST request, following any subsequent redirect. This is 135 # vulnerable to infinite loops, the same as #get_via_redirect. Headers are 136 # treated in the same way as #get. 137 def post_via_redirect(path, args={}, headers = {}) 138 post path, args, headers 139 follow_redirect! while redirect? 140 status 134 # Performs a GET request, following any subsequent redirect. 135 # See #request_via_redirect() for more information. 136 def get_via_redirect(path, parameters = nil, headers = nil) 137 request_via_redirect(:get, path, parameters, headers) 138 end 139 140 # Performs a POST request, following any subsequent redirect. 141 # See #request_via_redirect() for more information. 142 def post_via_redirect(path, parameters = nil, headers = nil) 143 request_via_redirect(:post, path, parameters, headers) 144 end 145 146 # Performs a PUT request, following any subsequent redirect. 147 # See #request_via_redirect() for more information. 148 def put_via_redirect(path, parameters = nil, headers = nil) 149 request_via_redirect(:put, path, parameters, headers) 150 end 151 152 # Performs a DELETE request, following any subsequent redirect. 153 # See #request_via_redirect() for more information. 154 def delete_via_redirect(path, parameters = nil, headers = nil) 155 request_via_redirect(:delete, path, parameters, headers) 141 156 end 142 157 trunk/actionpack/test/controller/integration_test.rb
r8426 r8429 50 50 end 51 51 52 def test_get_via_redirect 53 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } 54 55 @session.expects(:get).with(path,args,headers) 56 52 def test_request_via_redirect_uses_given_method 53 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} 54 @session.expects(:put).with(path, args, headers) 55 @session.stubs(:redirect?).returns(false) 56 @session.request_via_redirect(:put, path, args, headers) 57 end 58 59 def test_request_via_redirect_follows_redirects 60 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} 57 61 @session.stubs(:redirect?).returns(true, true, false) 58 62 @session.expects(:follow_redirect!).times(2) 59 63 @session.request_via_redirect(:get, path, args, headers) 64 end 65 66 def test_request_via_redirect_returns_status 67 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} 68 @session.stubs(:redirect?).returns(false) 60 69 @session.stubs(:status).returns(200) 61 assert_equal 200, @session.get_via_redirect(path, args, headers) 70 assert_equal 200, @session.request_via_redirect(:get, path, args, headers) 71 end 72 73 def test_get_via_redirect 74 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } 75 @session.expects(:request_via_redirect).with(:get, path, args, headers) 76 @session.get_via_redirect(path, args, headers) 62 77 end 63 78 64 79 def test_post_via_redirect 65 80 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } 66 67 @session.expects(:post).with(path,args,headers) 68 69 @session.stubs(:redirect?).returns(true, true, false) 70 @session.expects(:follow_redirect!).times(2) 71 72 @session.stubs(:status).returns(200) 73 assert_equal 200, @session.post_via_redirect(path, args, headers) 81 @session.expects(:request_via_redirect).with(:post, path, args, headers) 82 @session.post_via_redirect(path, args, headers) 83 end 84 85 def test_put_via_redirect 86 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } 87 @session.expects(:request_via_redirect).with(:put, path, args, headers) 88 @session.put_via_redirect(path, args, headers) 89 end 90 91 def test_delete_via_redirect 92 path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } 93 @session.expects(:request_via_redirect).with(:delete, path, args, headers) 94 @session.delete_via_redirect(path, args, headers) 74 95 end 75 96