aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen string literal in activemodel/Kir Shatrov2017-07-1616-0/+32
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0216-16/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-0116-0/+16
|
* Replace \Z to \zRyuta Kamizono2017-04-241-3/+3
| | | | \Z was a mistake of \z. Replace \Z to \z to prevent newly \Z added.
* Avoid converting integer as a string into floatnamusyaka2017-02-181-0/+9
|
* Remove deprecated behavior that halts callbacks when the return is falseRafael Mendonça França2017-02-071-8/+6
|
* Deprecate passing string to `:if` and `:unless` conditional options on ↵Ryuta Kamizono2017-02-042-10/+30
| | | | `set_callback` and `skip_callback`
* Do not rely on Ruby implementation in AM testKir Shatrov2016-11-191-3/+3
| | | | | | | | | | | | Now a few tests in ActiveModel rely on Ruby implementation and the fact that in MRI `97.18` as a float is greater than `97.18` as a BigDecimal. This is only relevant for MRI. On JRuby, comparing float to BigDecimal would be conversion of them to the same type and they will be equal. I'd like the ActiveModel test suite to be Ruby implementation-agnostic. Here we test ActiveModel, not the Ruby internals. This PR fixes a couple more JRuby tests.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-297-21/+21
|
* Removed deprecated :tokenizer in the length validatorRafael Mendonça França2016-10-101-36/+0
|
* improve error message when include assertions failMichael Grosser2016-09-162-11/+11
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-1/+1
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add test for allow_blank in numericality validationNicolai Reuschling2016-08-281-0/+7
| | | | Signed-off-by: Guillermo Iguaran <guilleiguaran@gmail.com>
* Add three new rubocop rulesRafael Mendonça França2016-08-167-16/+16
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* code gardening: removes redundant selfsXavier Noria2016-08-081-16/+16
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-072-2/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-0611-12/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-17/+17
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-4/+2
|
* modernizes hash syntax in activemodelXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activemodel/testXavier Noria2016-08-0616-215/+215
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Add edge cases to Time/Date/DateTime inclusion validation testsojab2016-03-241-3/+17
|
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-222-4/+4
|
* Failing Tests for Validating String NumbericalityRobert Eshleman2015-12-221-0/+42
| | | | | | | | | | | Covers Regressions: * <= * < * == * > * >= * other than
* Deprecate passing string to define callback.yui-knk2015-12-161-0/+1
|
* 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.
* Merge pull request #19851 from repinel/numericality-validation2Sean Griffin2015-10-201-1/+36
|\ | | | | Use the post-type-cast version of the attribute to validate numericality
| * 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]
* | Validate multiple contexts on `valid?` and `invalid?` at once.Dmitry Polushkin2015-09-071-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: ```ruby class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => true person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} ```
* | Revert "Merge pull request #21069 from ↵Rafael Mendonça França2015-09-071-19/+0
| | | | | | | | | | | | | | | | | | dmitry/feature/validate-multiple-contexts-at-once" This reverts commit 51dd2588433457960cca592d5b5dac6e0537feac, reversing changes made to ecb4e4b21b3222b823fa24d4a0598b1f2f63ecfb. This broke Active Record tests
* | Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-onceRafael Mendonça França2015-09-071-0/+19
|\ \ | | | | | | | | | Validate multiple contexts on `valid?` and `invalid?` at once
| * | Validate multiple contexts on `valid?` and `invalid?` at once.Dmitry Polushkin2015-07-301-0/+19
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: ```ruby class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => true person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} ```
* | Add missing test for #17351Aditya Kapoor2015-09-011-0/+14
| |
* | pass the correct argument to mock on a test of `validates_length_of`yuuji.yaginuma2015-07-281-1/+1
|/
* Removes unnecessary comments from i18n validations tests [ci skip]Zamith2015-07-111-61/+2
| | | | | | These comments do not add a lot to the readability, grepability or overall understanding of the tests, therefore I believe they can be safely removed.
* Remove the reference to mocha in activemodelZamith2015-07-111-27/+27
| | | | | Activemodel is no longer dependent on mocha, so we can make the comments more generic.
* Use private method call assertions in Active Model tests.Kasper Timm Hansen2015-07-102-35/+32
| | | | Also fix Minitest constant reference.
* Improve Validation Helpers' documentation comments and testsRadan Skoric2015-06-272-0/+31
|
* Fix typo in AM I18n validation test name [skip ci]Anton Davydov2015-06-091-1/+1
|
* Remove use of mocha from Active ModelRoque Pinel2015-05-282-35/+71
|
* Deprecate the `:tokenizer` option to `validates_length_of`Sean Griffin2015-03-291-4/+16
| | | | | | | | As demonstrated by #19570, this option is severely limited, and satisfies an extremely specific use case. Realistically, there's not much reason for this option to exist. Its functionality can be trivially replicated with a normal Ruby method. Let's deprecate this option, in favor of the simpler solution.
* Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methodsWojciech Wnętrzak2015-02-191-1/+1
| | | | without replacement.
* Merge pull request #16381 from kakipo/validate-length-tokenizerRafael Mendonça França2015-02-131-0/+13
|\ | | | | | | Allow symbol as values for `tokenizer` of `LengthValidator`
| * Allow symbol as values for `tokenize` of `LengthValidator`kakipo2014-08-031-0/+13
| |
* | Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-0315-16/+0
| | | | | | | | onwards.
* | Merge pull request #18439 from mokhan/validates-acceptance-of-arraySean Griffin2015-01-121-0/+6
|\ \ | | | | | | allow '1' or true for acceptance validation.
| * | allow '1' or true for acceptance validation.mo khan2015-01-101-0/+6
| | |