diff options
author | Matthew Draper <matthew@trebex.net> | 2017-05-28 11:00:07 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-28 11:00:07 +0930 |
commit | 1758292f55d2a938659b47fe19b23ced4881cfad (patch) | |
tree | 7b3f766e824c79e57193ea3c6f3060cdb1ba98eb /activerecord/test/cases | |
parent | 94d94d0ac3c1026185805905bcaad8e16e05d0ac (diff) | |
parent | d83b8e65102d625c9024cd9a2727a10b0ef83b79 (diff) | |
download | rails-1758292f55d2a938659b47fe19b23ced4881cfad.tar.gz rails-1758292f55d2a938659b47fe19b23ced4881cfad.tar.bz2 rails-1758292f55d2a938659b47fe19b23ced4881cfad.zip |
Merge pull request #29249 from bradleypriest/numericality-precision-regression
Fix regression in Numericality validator
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/validations_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 5d9aa99497..a305aa295a 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -167,6 +167,20 @@ class ValidationsTest < ActiveRecord::TestCase assert topic.valid? end + def test_numericality_validation_checks_against_raw_value + klass = Class.new(Topic) do + def self.model_name + ActiveModel::Name.new(self, nil, "Topic") + end + attribute :wibble, :decimal, scale: 2, precision: 9 + validates_numericality_of :wibble, greater_than_or_equal_to: BigDecimal.new("97.18") + end + + assert_not klass.new(wibble: "97.179").valid? + assert_not klass.new(wibble: 97.179).valid? + assert_not klass.new(wibble: BigDecimal.new("97.179")).valid? + end + def test_acceptance_validator_doesnt_require_db_connection klass = Class.new(ActiveRecord::Base) do self.table_name = "posts" |