diff options
author | Samuel Elliott <sam@lenary.co.uk> | 2010-01-17 12:15:52 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-17 14:40:10 +0100 |
commit | 31ea83eb898786f853bd7ce7075986fa120f949d (patch) | |
tree | f2336037a93c72680db7f9e8030939b85f73891b /activemodel/test/cases | |
parent | c0d31ca41b2f019d3bf940ac79f104c412b115bf (diff) | |
download | rails-31ea83eb898786f853bd7ce7075986fa120f949d.tar.gz rails-31ea83eb898786f853bd7ce7075986fa120f949d.tar.bz2 rails-31ea83eb898786f853bd7ce7075986fa120f949d.zip |
Adding Proc support to validation messages so that they can become a little more dynamic, allowing for customisations during the request [#3514 status:resolved].
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index 38a2a716a7..eb100d1c35 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -212,4 +212,12 @@ class ValidationsTest < ActiveModel::TestCase all_errors = t.errors.to_a assert_deprecated { assert_equal all_errors, t.errors.each_full{|err| err} } end + + def test_validation_with_message_as_proc + Topic.validates_presence_of(:title, :message => proc { "no blanks here".upcase }) + + t = Topic.new + assert !t.valid? + assert ["NO BLANKS HERE"], t.errors[:title] + end end |