Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for interpolation with passing of data along with record #24431

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions activemodel/test/cases/validations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,12 @@ def test_validation_with_message_as_proc_that_takes_a_record_as_a_parameter
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