diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-17 00:34:35 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-17 00:34:35 -0700 |
commit | 2f87b724d2eaf1e9f67a1827ca7cb140fbbd4f95 (patch) | |
tree | e130b027cbb4e308024366cc85afb9a2609c915b /activemodel/test/cases/errors_test.rb | |
parent | 8919a68b961e2789286a1f9e71fd1b8a9ee7d3e0 (diff) | |
parent | 180d4137ca8222cb90a285bfd60265ae93c56968 (diff) | |
download | rails-2f87b724d2eaf1e9f67a1827ca7cb140fbbd4f95.tar.gz rails-2f87b724d2eaf1e9f67a1827ca7cb140fbbd4f95.tar.bz2 rails-2f87b724d2eaf1e9f67a1827ca7cb140fbbd4f95.zip |
Merge pull request #3319 from martinsvalin/active_model_errors_fixes
ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add
Diffstat (limited to 'activemodel/test/cases/errors_test.rb')
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 4c76bb43a8..784a2b2709 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -66,6 +66,20 @@ class ErrorsTest < ActiveModel::TestCase assert_equal ["can not be blank"], person.errors[:name] end + test "should be able to add an error with a symbol" do + person = Person.new + person.errors.add(:name, :blank) + message = person.errors.generate_message(:name, :blank) + assert_equal [message], person.errors[:name] + end + + test "should be able to add an error with a proc" do + person = Person.new + message = Proc.new { "can not be blank" } + person.errors.add(:name, message) + assert_equal ["can not be blank"], person.errors[:name] + end + test 'should respond to size' do person = Person.new person.errors.add(:name, "can not be blank") @@ -112,5 +126,12 @@ class ErrorsTest < ActiveModel::TestCase assert_equal ["is invalid"], hash[:email] end + test "generate_message should work without i18n_scope" do + person = Person.new + assert !Person.respond_to?(:i18n_scope) + assert_nothing_raised { + person.errors.generate_message(:name, :blank) + } + end end |