From 534dc4ca1a730bff3fc9fe116bec25172c7c8afc Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Fri, 17 Feb 2012 12:12:10 +0200 Subject: AM::Errors: allow :full_messages parameter for #as_json --- activemodel/test/cases/errors_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activemodel/test/cases') 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) -- cgit v1.2.3