aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-09-17 11:34:40 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-09-17 11:34:40 -0700
commitb5dd1b659987bb6117c0f1657e66dc395cfbed5e (patch)
treec6b1965c4041dd369d671413875bcf7e6645df93 /activeresource
parentc9d3c48dc6389feb2001372cd76e96274e773c9b (diff)
downloadrails-b5dd1b659987bb6117c0f1657e66dc395cfbed5e.tar.gz
rails-b5dd1b659987bb6117c0f1657e66dc395cfbed5e.tar.bz2
rails-b5dd1b659987bb6117c0f1657e66dc395cfbed5e.zip
Fix brittle content-type check. [#1956 state:committed]
Diffstat (limited to 'activeresource')
-rw-r--r--activeresource/lib/active_resource/validations.rb4
-rw-r--r--activeresource/test/cases/base_errors_test.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index d4d282e273..67b69fa505 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -93,9 +93,9 @@ module ActiveResource
# content-type of the error-block received
def load_remote_errors(remote_errors, save_cache = false ) #:nodoc:
case remote_errors.response['Content-Type']
- when 'application/xml'
+ when /xml/
errors.from_xml(remote_errors.response.body, save_cache)
- when 'application/json'
+ when /json/
errors.from_json(remote_errors.response.body, save_cache)
end
end
diff --git a/activeresource/test/cases/base_errors_test.rb b/activeresource/test/cases/base_errors_test.rb
index eca00e9ca8..1eb7765132 100644
--- a/activeresource/test/cases/base_errors_test.rb
+++ b/activeresource/test/cases/base_errors_test.rb
@@ -4,8 +4,8 @@ require "fixtures/person"
class BaseErrorsTest < Test::Unit::TestCase
def setup
ActiveResource::HttpMock.respond_to do |mock|
- mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml'}
- mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json'}
+ mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml; charset=utf-8'}
+ mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json; charset=utf-8'}
end
end