diff options
author | Krekoten' Marjan <krekoten@gmail.com> | 2010-11-30 22:48:19 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-12-01 00:03:42 +0800 |
commit | a9b666b51d28b2e74da630c31327dee7cbe96d37 (patch) | |
tree | 5368f8025e154a17c1c91a72273162be359794c4 /activemodel/test/cases | |
parent | 76a15dd0599779f86bda063bb545bba68c6ff17b (diff) | |
download | rails-a9b666b51d28b2e74da630c31327dee7cbe96d37.tar.gz rails-a9b666b51d28b2e74da630c31327dee7cbe96d37.tar.bz2 rails-a9b666b51d28b2e74da630c31327dee7cbe96d37.zip |
Fix generation of wrong json string when field has multiple errors
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 79b45bb298..1958ed112c 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -61,5 +61,15 @@ class ErrorsTest < ActiveModel::TestCase assert_equal ["name can not be blank", "name can not be nil"], person.errors.to_a end + + test 'to_json should return valid json string' do + person = Person.new + person.errors.add(:name, "can not be blank") + person.errors.add(:name, "can not be nil") + + hash = ActiveSupport::OrderedHash[:name, ["can not be blank", "can not be nil"]] + + assert_equal person.errors.to_json, hash.to_json + end end |