diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-04-06 01:04:10 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-04-06 01:04:10 -0300 |
commit | 2d20bdfe1d8928ccedd38cfab6fcfdd190c7d5de (patch) | |
tree | 6b9b4772b84443c4068b4f4d23b382bde97efc97 | |
parent | 659b104a006a346644fcbc4c6a40e8b717947429 (diff) | |
parent | 1f99bdb62098095cccea0167155998eae492923f (diff) | |
download | rails-2d20bdfe1d8928ccedd38cfab6fcfdd190c7d5de.tar.gz rails-2d20bdfe1d8928ccedd38cfab6fcfdd190c7d5de.tar.bz2 rails-2d20bdfe1d8928ccedd38cfab6fcfdd190c7d5de.zip |
Merge pull request #24431 from vipulnsward/24119-followup
Add test case for interpolation with passing of data along with record
-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 18b8d9e4af..2a4e9f842f 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -452,4 +452,12 @@ class ValidationsTest < ActiveModel::TestCase assert t.invalid? assert_equal ["You have failed me for the last time, Admiral."], t.errors[:title] end + + def test_validation_with_message_as_proc_that_takes_record_and_data_as_a_parameters + Topic.validates_presence_of(:title, message: proc { |record, data| "#{data[:attribute]} is missing. You have failed me for the last time, #{record.author_name}." }) + + t = Topic.new(author_name: 'Admiral') + assert t.invalid? + assert_equal ["Title is missing. You have failed me for the last time, Admiral."], t.errors[:title] + end end |