diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2012-02-17 12:12:10 +0200 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2012-02-20 11:17:11 +0200 |
commit | 534dc4ca1a730bff3fc9fe116bec25172c7c8afc (patch) | |
tree | 905a0e87a2adea890348e29e37e3906dc61ef018 /activemodel/test/cases | |
parent | decafdd57a2c992a15df894cc43cd0a7ff6ea985 (diff) | |
download | rails-534dc4ca1a730bff3fc9fe116bec25172c7c8afc.tar.gz rails-534dc4ca1a730bff3fc9fe116bec25172c7c8afc.tar.bz2 rails-534dc4ca1a730bff3fc9fe116bec25172c7c8afc.zip |
AM::Errors: allow :full_messages parameter for #as_json
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 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) |