aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource
diff options
context:
space:
mode:
authorChad Woolley <thewoolleyman@gmail.com>2009-10-04 01:50:47 -0700
committerCarl Lerche <carllerche@mac.com>2009-10-08 10:45:00 -0700
commit32cea98c3b5bd077692f5b20756e0e3c75e0c524 (patch)
tree4378c2f7f7e165d350b282f2fe1e14afa8d9891c /activeresource
parent28bd0873ff7aae8e5949dc77f1f8b78109cd38f1 (diff)
downloadrails-32cea98c3b5bd077692f5b20756e0e3c75e0c524.tar.gz
rails-32cea98c3b5bd077692f5b20756e0e3c75e0c524.tar.bz2
rails-32cea98c3b5bd077692f5b20756e0e3c75e0c524.zip
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>
Diffstat (limited to 'activeresource')
-rw-r--r--activeresource/lib/active_resource/exceptions.rb5
-rw-r--r--activeresource/test/connection_test.rb2
2 files changed, 5 insertions, 2 deletions
diff --git a/activeresource/lib/active_resource/exceptions.rb b/activeresource/lib/active_resource/exceptions.rb
index 0631cdcf9f..0f4549fd73 100644
--- a/activeresource/lib/active_resource/exceptions.rb
+++ b/activeresource/lib/active_resource/exceptions.rb
@@ -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
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb
index d7466c65b4..2a3e04272a 100644
--- a/activeresource/test/connection_test.rb
+++ b/activeresource/test/connection_test.rb
@@ -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