diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-03-04 18:50:56 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-03-04 18:51:34 +0100 |
commit | b501ee47fa3f877f8b8028e732f8ef8a22cc75fb (patch) | |
tree | 86ae07db52a22da555b1cea3e14b76630bc1a7fc /activemodel/test/cases | |
parent | b359c5db9f0e7dfb2cbf34362a9b310cf5aadd3a (diff) | |
download | rails-b501ee47fa3f877f8b8028e732f8ef8a22cc75fb.tar.gz rails-b501ee47fa3f877f8b8028e732f8ef8a22cc75fb.tar.bz2 rails-b501ee47fa3f877f8b8028e732f8ef8a22cc75fb.zip |
`validates_confirmation_of` does not override writer methods.
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/validations/confirmation_validation_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/confirmation_validation_test.rb b/activemodel/test/cases/validations/confirmation_validation_test.rb index f7556a249f..814eec3f59 100644 --- a/activemodel/test/cases/validations/confirmation_validation_test.rb +++ b/activemodel/test/cases/validations/confirmation_validation_test.rb @@ -71,4 +71,35 @@ class ConfirmationValidationTest < ActiveModel::TestCase I18n.backend = @old_backend end + test "does not override confirmation reader if present" do + klass = Class.new do + include ActiveModel::Validations + + def title_confirmation + "expected title" + end + + validates_confirmation_of :title + end + + assert_equal "expected title", klass.new.title_confirmation, + "confirmation validation should not override the reader" + end + + test "does not override confirmation writer if present" do + klass = Class.new do + include ActiveModel::Validations + + def title_confirmation=(value) + @title_confirmation = "expected title" + end + + validates_confirmation_of :title + end + + model = klass.new + model.title_confirmation = "new title" + assert_equal "expected title", model.title_confirmation, + "confirmation validation should not override the writer" + end end |