aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type/float_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix non_numeric_string?Yoshiyuki Kinjo2018-09-071-1/+4
| | | | | | | | | | | | | | | | For example, dirty checking was not right for the following case: ``` model.int_column = "+5" model.float_column = "0.5E+1" model.decimal_column = "0.5e-3" ``` It is enough to see whether leading character is a digit for avoiding invalid numeric expression like 'wibble' to be type-casted to 0, as this method's comment says. Fixes #33801
* Add missing autoload `Type` (#31123)Ryuta Kamizono2017-11-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | | Attribute modules (`Attribute`, `Attributes`, `AttributeSet`) uses `Type`, but referencing `Type` before the modules still fail. ``` % ./bin/test -w test/cases/attribute_test.rb -n test_with_value_from_user_validates_the_value Run options: -n test_with_value_from_user_validates_the_value --seed 31876 E Error: ActiveModel::AttributeTest#test_with_value_from_user_validates_the_value: NameError: uninitialized constant ActiveModel::AttributeTest::Type /Users/kamipo/src/github.com/rails/rails/activemodel/test/cases/attribute_test.rb:233:in `block in <class:AttributeTest>' bin/test test/cases/attribute_test.rb:232 Finished in 0.002985s, 335.0479 runs/s, 335.0479 assertions/s. 1 runs, 1 assertions, 0 failures, 1 errors, 0 skips ``` Probably we need more autoloading at least `Type`.
* Use frozen string literal in activemodel/Kir Shatrov2017-07-161-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix invalid string Decimal casting under ruby 2.4John Hawthorn2017-02-241-0/+8
| | | | | | | | | | | | | | | | | | | In Ruby 2.4, BigDecimal(), as used by the Decimal cast, was changed so that it will raise ArgumentError when passed an invalid string, in order to be more consistent with Integer(), Float(), etc. The other numeric types use ex. to_i and to_f. Unfortunately, we can't simply change BigDecimal() to to_d. String#to_d raises errors like BigDecimal(), unlike all the other to_* methods (this should probably be filed as a ruby bug). Instead, this simulates the existing behaviour and the behaviour of the other to_* methods by finding a numeric string at the start of the passed in value, and parsing that using BigDecimal(). See also https://bugs.ruby-lang.org/issues/10286 https://github.com/ruby/bigdecimal/commit/3081a627cebdc1fc119425c7a9f009dbb6bec8e8
* Refactored ActiveModel::Type tests into their own filesIain Beeston2016-10-151-0/+22