diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-02-20 01:25:28 -0800 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-02-20 01:25:28 -0800 |
commit | e1c381603d277bc4d6cb430d53a5f1d1aca377e7 (patch) | |
tree | 11b93900af2583008180799f50e141703af83e78 /activemodel/test/cases/errors_test.rb | |
parent | 1ef12fd1727909f7a33fd7f2d750d48d7f9b47e9 (diff) | |
parent | 534dc4ca1a730bff3fc9fe116bec25172c7c8afc (diff) | |
download | rails-e1c381603d277bc4d6cb430d53a5f1d1aca377e7.tar.gz rails-e1c381603d277bc4d6cb430d53a5f1d1aca377e7.tar.bz2 rails-e1c381603d277bc4d6cb430d53a5f1d1aca377e7.zip |
Merge pull request #5075 from bogdan/json_full_messages
AM::Errors: allow :full_messages parameter for #to_json
Diffstat (limited to 'activemodel/test/cases/errors_test.rb')
-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 7a610e0c2c..3bc0d58351 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -184,6 +184,16 @@ class ErrorsTest < ActiveModel::TestCase assert_equal ["is invalid"], hash[:email] end + test 'should return a JSON hash representation of the errors with full messages' do + person = Person.new + person.errors.add(:name, "can not be blank") + person.errors.add(:name, "can not be nil") + person.errors.add(:email, "is invalid") + hash = person.errors.as_json(:full_messages => true) + assert_equal ["name can not be blank", "name can not be nil"], hash[:name] + assert_equal ["email is invalid"], hash[:email] + end + test "generate_message should work without i18n_scope" do person = Person.new assert !Person.respond_to?(:i18n_scope) |