mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ruby 1.9: Fix ActiveResource::ConnectionError#to_s when @response does not respond to #code or #message
Signed-off-by: Carl Lerche <carllerche@mac.com>
This commit is contained in:
parent
28bd0873ff
commit
32cea98c3b
2 changed files with 5 additions and 2 deletions
|
@ -8,7 +8,10 @@ module ActiveResource
|
|||
end
|
||||
|
||||
def to_s
|
||||
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
|
||||
message = "Failed."
|
||||
message << " Response code = #{response.code}." if response.respond_to?(:code)
|
||||
message << " Response message = #{response.message}." if response.respond_to?(:message)
|
||||
message
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|||
begin
|
||||
handle_response ResponseHeaderStub.new(405, "HTTP Failed...", "GET, POST")
|
||||
rescue ActiveResource::MethodNotAllowed => e
|
||||
assert_equal "Failed with 405 HTTP Failed...", e.message
|
||||
assert_equal "Failed. Response code = 405. Response message = HTTP Failed....", e.message
|
||||
assert_equal [:get, :post], e.allowed_methods
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue