diff options
author | Jatinder Singh <jatinder.saundh@gmail.com> | 2010-01-27 15:28:32 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-01-27 18:27:18 -0800 |
commit | e87748869af238fe6bcb78e8d9a8d2bbc3734039 (patch) | |
tree | d4fcaebe619db3a8cb82ae14e2b6719ac540dc84 /activeresource/test | |
parent | e98f9579c472e75f5a8c0678f2fc54b2d681e3ec (diff) | |
download | rails-e87748869af238fe6bcb78e8d9a8d2bbc3734039.tar.gz rails-e87748869af238fe6bcb78e8d9a8d2bbc3734039.tar.bz2 rails-e87748869af238fe6bcb78e8d9a8d2bbc3734039.zip |
Use format of ARes rather than content-type of remote errors to load errors.
[#1956 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/cases/base_errors_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activeresource/test/cases/base_errors_test.rb b/activeresource/test/cases/base_errors_test.rb index 1eb7765132..b4fd75fba3 100644 --- a/activeresource/test/cases/base_errors_test.rb +++ b/activeresource/test/cases/base_errors_test.rb @@ -69,6 +69,19 @@ class BaseErrorsTest < Test::Unit::TestCase end end + def test_should_mark_as_invalid_when_content_type_is_unavailable_in_response_header + 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, {} + 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, {} + end + + [ :json, :xml ].each do |format| + invalid_user_using_format(format) do + assert !@person.valid? + end + end + end + private def invalid_user_using_format(mime_type_reference) previous_format = Person.format |