aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases
diff options
context:
space:
mode:
authorMartin Svalin <martin@lite.nu>2011-10-11 21:44:22 +0200
committerMartin Svalin <martin@lite.nu>2011-10-17 09:22:08 +0200
commit180d4137ca8222cb90a285bfd60265ae93c56968 (patch)
treee130b027cbb4e308024366cc85afb9a2609c915b /activemodel/test/cases
parent8919a68b961e2789286a1f9e71fd1b8a9ee7d3e0 (diff)
downloadrails-180d4137ca8222cb90a285bfd60265ae93c56968.tar.gz
rails-180d4137ca8222cb90a285bfd60265ae93c56968.tar.bz2
rails-180d4137ca8222cb90a285bfd60265ae93c56968.zip
ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r--activemodel/test/cases/errors_test.rb21
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