aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations/numericality_validation_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* applies new string literal convention in activemodel/testXavier Noria2016-08-061-39/+39
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Failing Tests for Validating String NumbericalityRobert Eshleman2015-12-221-0/+42
| | | | | | | | | | | Covers Regressions: * <= * < * == * > * >= * other than
* Really fix test failures caused by #19851Sean Griffin2015-10-201-5/+6
| | | | | | | Ok, this explains why the branch showed as green. We don't run files in isolation for PRs, only for master. Active Support monkeypatches `BigDecimal#to_s`, so the generated error message was different depending on if the file was run in isolation
* Fix test failures caused by #19851Sean Griffin2015-10-201-5/+5
| | | | | | | | | The error message when asserting `greater_than: BigDecimal.new` will give an error message based on how BigDecimal displays itself. Big decimal appears to always use scientific notation. This might not be the best error message for the general case, but the general case wouldn't use big decimal for the validation. And if they do, they likely need this level of precision.
* Conditionally convert the raw_value received by the numeric validator.Roque Pinel2015-07-111-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the issue where you may be comparing (using a numeric validator such as `greater_than`) numbers of a specific Numeric type such as `BigDecimal`. Previous behavior took the numeric value to be validated and unconditionally converted to Float. For example, due to floating point precision, this can cause issues when comparing a Float to a BigDecimal. Consider the following: ``` validates :sub_total, numericality: { greater_than: BigDecimal('97.18') } ``` If the `:sub_total` value BigDecimal.new('97.18') was validated against the above, the following would be valid since `:sub_total` is converted to a Float regardless of its original type. The result therefore becomes Kernel.Float(97.18) > BigDecimal.new('97.18') The above illustrated behavior is corrected with this patch by conditionally converting the value to validate to float. Use the post-type-cast version of the attribute to validate numericality [Roque Pinel & Trevor Wistaff]
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-2/+2
|
* `only_integer` of `NumericalityValidator` now allows procs and symbolsRobin Mehner2014-06-221-0/+15
|
* Completely remove potential global state leaks in ActiveModel tests.Zuhao Wan2014-03-111-0/+2
| | | | ActiveModel tests can now be run in random order.
* Use the new clear_validators! api to reset validators in testsCarlos Antonio da Silva2014-01-271-2/+2
|
* Convert ActiveModel to 1.9 hash syntax.Patrick Robertson2013-05-011-23/+23
| | | | | I also attempted to fix other styleguide violations such as { a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
* added :other_than => :!= option to numericality validatorJakub Kuźma2011-12-211-0/+7
|
* Active Model typos.R.T. Lechow2011-03-051-1/+1
|
* Missing BigDecimal dependencyJeremy Kemper2010-06-271-0/+2
|
* Add a valid hex that shouldn't be valid to ActiveModel numericality tests ↵rohit2010-05-181-1/+1
| | | | | | [#4622 state:commited] Signed-off-by: José Valim <jose.valim@gmail.com>
* Valid hex strings aren't valid float column values, to match the integer ↵Jeremy Kemper2010-05-171-1/+1
| | | | restriction. [#4622 state:resolved]
* removed AR from all AMo tests, including any unneeded files (schema, ↵Josh Kalderimis2010-05-091-2/+0
| | | | fixtures and test helper)
* removed an old unused model in the AMo tests which also removes another AR ↵Josh Kalderimis2010-05-091-1/+0
| | | | dependency
* removed use of AR in AMo tests and removed testing of scopes (:on) in ↵Josh Kalderimis2010-05-081-5/+5
| | | | individual validation tests and moved them to their own test file
* Favor %{} in all code instead of (deprecated) {{}} as interpolation syntax ↵Lawrence Pit2010-05-031-2/+2
| | | | | | for I18n Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix typos and add tests to ensure they will be caught the next time.José Valim2010-01-111-0/+8
|
* No need to use ValidationsRepairHelper hack on ActiveModel anymore, ↵José Valim2009-12-231-29/+12
| | | | Model.reset_callbacks(:validate) is enough. However, tests in ActiveRecord are still coupled, so moved ValidationsRepairHelper back there.
* added proc and symbol support to validates_numericality_of [#3049 ↵Kane2009-08-311-0/+18
| | | | | | state:resolved] Signed-off-by: Joshua Peek <josh@joshpeek.com>
* Add ActiveModel::Validations tests for regular ruby classesPratik Naik2009-03-201-18/+34
|
* Deprecate Error#on(attribute) in favour of Errors#[attribute]Pratik Naik2009-03-201-2/+2
|
* TestDatabase -> TestsDatabasePratik Naik2009-03-201-2/+2
|
* Move relevant validation tests from Active Record to Active ModelPratik Naik2009-03-201-0/+163