aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-11-06 18:13:37 -0500
committerGitHub <noreply@github.com>2017-11-06 18:13:37 -0500
commit9042ced124874a200b134ec3a4441ab6e2c1be73 (patch)
tree5e1e5f4f8cb017a689742b741ee1b593a1ce5f07 /activemodel/test/cases
parent165d5b601d44495452dcebba5a61b31b3be36da7 (diff)
parent7308991630af3fb8a2a7e2cde9fd322316153ec2 (diff)
downloadrails-9042ced124874a200b134ec3a4441ab6e2c1be73.tar.gz
rails-9042ced124874a200b134ec3a4441ab6e2c1be73.tar.bz2
rails-9042ced124874a200b134ec3a4441ab6e2c1be73.zip
Merge pull request #31058 from bogdanvlviv/ConfirmationValidator-with_false_value
Execute `ConfirmationValidator` validation when `_confirmation`'s value is `false`
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r--activemodel/test/cases/validations/confirmation_validation_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/confirmation_validation_test.rb b/activemodel/test/cases/validations/confirmation_validation_test.rb
index e84415a868..8b2c65289b 100644
--- a/activemodel/test/cases/validations/confirmation_validation_test.rb
+++ b/activemodel/test/cases/validations/confirmation_validation_test.rb
@@ -37,6 +37,19 @@ class ConfirmationValidationTest < ActiveModel::TestCase
assert t.valid?
end
+ def test_validates_confirmation_of_with_boolean_attribute
+ Topic.validates_confirmation_of(:approved)
+
+ t = Topic.new(approved: true, approved_confirmation: nil)
+ assert t.valid?
+
+ t.approved_confirmation = false
+ assert t.invalid?
+
+ t.approved_confirmation = true
+ assert t.valid?
+ end
+
def test_validates_confirmation_of_for_ruby_class
Person.validates_confirmation_of :karma