diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-26 20:57:08 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-26 20:57:08 +0000 |
commit | 849038ee514b6ddfb0876c293c5b87e3d960f0bf (patch) | |
tree | 8dd96b8208b18ab5276554e81bc595aa5c7363fe /activeresource/test | |
parent | 404a357013f6a544692841770b03a1ccf0b57ea7 (diff) | |
download | rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.tar.gz rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.tar.bz2 rails-849038ee514b6ddfb0876c293c5b87e3d960f0bf.zip |
Recognize and raise an exception on 405 Method Not Allowed responses. Closes #7692.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/connection_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb index 67d5553e72..13b518d782 100644 --- a/activeresource/test/connection_test.rb +++ b/activeresource/test/connection_test.rb @@ -41,6 +41,9 @@ class ConnectionTest < Test::Unit::TestCase # 404 is a missing resource. assert_response_raises ActiveResource::ResourceNotFound, 404 + # 405 is a missing not allowed error + assert_response_raises ActiveResource::MethodNotAllowed, 405 + # 409 is an optimistic locking error assert_response_raises ActiveResource::ResourceConflict, 409 @@ -63,6 +66,16 @@ class ConnectionTest < Test::Unit::TestCase end end + ResponseHeaderStub = Struct.new(:code, 'Allow') + def test_should_return_allowed_methods_for_method_no_allowed_exception + begin + handle_response ResponseHeaderStub.new(405, "GET, POST") + rescue ActiveResource::MethodNotAllowed => e + assert_equal "Failed with 405", e.message + assert_equal [:get, :post], e.allowed_methods + end + end + def test_initialize_raises_argument_error_on_missing_site assert_raise(ArgumentError) { ActiveResource::Connection.new(nil) } end |