diff options
author | David Trasbo <me@dtrasbo.com> | 2010-06-26 19:16:17 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 19:23:10 +0200 |
commit | df083b482d3f22aebb5e48e608811a740037d2aa (patch) | |
tree | 88f9660353e6e21456e3a8b69fc56f884b76b5f3 /activeresource/test/cases | |
parent | 7eb5766bd1d7300e598fb81769da79ffbaa7b62a (diff) | |
download | rails-df083b482d3f22aebb5e48e608811a740037d2aa.tar.gz rails-df083b482d3f22aebb5e48e608811a740037d2aa.tar.bz2 rails-df083b482d3f22aebb5e48e608811a740037d2aa.zip |
Make sure ActiveResource::Errors#from_json doesn't pass nil to #from_array [#3650 state:commited]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activeresource/test/cases')
-rw-r--r-- | activeresource/test/cases/base_errors_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activeresource/test/cases/base_errors_test.rb b/activeresource/test/cases/base_errors_test.rb index b4fd75fba3..5063916d10 100644 --- a/activeresource/test/cases/base_errors_test.rb +++ b/activeresource/test/cases/base_errors_test.rb @@ -17,7 +17,7 @@ class BaseErrorsTest < Test::Unit::TestCase end end - def test_should_parse_xml_errors + def test_should_parse_json_and_xml_errors [ :json, :xml ].each do |format| invalid_user_using_format(format) do assert_kind_of ActiveResource::Errors, @person.errors @@ -26,6 +26,17 @@ class BaseErrorsTest < Test::Unit::TestCase end end + def test_should_parse_json_errors_when_no_errors_key + ActiveResource::HttpMock.respond_to do |mock| + mock.post "/people.json", {}, '{}', 422, {'Content-Type' => 'application/json; charset=utf-8'} + end + + invalid_user_using_format(:json) do + assert_kind_of ActiveResource::Errors, @person.errors + assert_equal 0, @person.errors.size + end + end + def test_should_parse_errors_to_individual_attributes [ :json, :xml ].each do |format| invalid_user_using_format(format) do |