diff options
author | Olli Jokinen <olli.jokinen@enemy.fi> | 2011-12-01 15:32:59 +0200 |
---|---|---|
committer | Olli Jokinen <olli.jokinen@enemy.fi> | 2011-12-01 15:32:59 +0200 |
commit | b4e1903d23a760028d58bc3bb20a1d491bfd4a4b (patch) | |
tree | a40bdce1bd4800124ab6eaed2a6be017bf9cfd3d /activeresource/test/cases/connection_test.rb | |
parent | fae9ad9c712decef70b379f5aa1faa0149902831 (diff) | |
parent | 1e51cd957e3c90f4be35f1f0c4c380d8f7d40d66 (diff) | |
download | rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.tar.gz rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.tar.bz2 rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'activeresource/test/cases/connection_test.rb')
-rw-r--r-- | activeresource/test/cases/connection_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activeresource/test/cases/connection_test.rb b/activeresource/test/cases/connection_test.rb index 09df0fb678..535107aeef 100644 --- a/activeresource/test/cases/connection_test.rb +++ b/activeresource/test/cases/connection_test.rb @@ -2,6 +2,7 @@ require 'abstract_unit' class ConnectionTest < Test::Unit::TestCase ResponseCodeStub = Struct.new(:code) + RedirectResponseStub = Struct.new(:code, :Location) def setup @conn = ActiveResource::Connection.new('http://localhost') @@ -38,6 +39,18 @@ class ConnectionTest < Test::Unit::TestCase assert_equal expected, handle_response(expected) end + # 301 is moved permanently (redirect) + assert_redirect_raises 301 + + # 302 is found (redirect) + assert_redirect_raises 302 + + # 303 is see other (redirect) + assert_redirect_raises 303 + + # 307 is temporary redirect + assert_redirect_raises 307 + # 400 is a bad request (e.g. malformed URI or missing request parameter) assert_response_raises ActiveResource::BadRequest, 400 @@ -247,6 +260,12 @@ class ConnectionTest < Test::Unit::TestCase end end + def assert_redirect_raises(code) + assert_raise(ActiveResource::Redirection, "Expected response code #{code} to raise ActiveResource::Redirection") do + handle_response RedirectResponseStub.new(code, 'http://example.com/') + end + end + def handle_response(response) @conn.__send__(:handle_response, response) end |