aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-2/+2
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-28/+28
|
* 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
|
* improve error message when include assertions failMichael Grosser2016-09-161-6/+6
| | | | | | 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
* Add three new rubocop rulesRafael Mendonça França2016-08-161-5/+5
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies new string literal convention in activemodel/testXavier Noria2016-08-061-21/+21
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add test case for interpolation with passing of data along with record ↵Vipul A M2016-04-051-0/+8
| | | | attribute in error message, where a proc is passed.
* Allow passing record being validated to error message generatorPrathamesh Sonpatki2016-04-051-0/+8
| | | | | | | | | - Pass object to I18n helper so that when calling message proc, it will pass that object as argument to the proc and we can generate custom error messages based on current record being validated. - Based on https://github.com/rails/rails/issues/856. [Łukasz Bandzarewicz, Prathamesh Sonpatki]
* Move the `validate!` method to `ActiveModel::Validations`.Lucas Mazza2015-02-201-0/+19
|
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* - Fixed unused variableVipul A M2014-12-211-3/+2
| | | | - Changed test to verify complete message instead of verifying if message contains text.
* Pass through the `prepend` option to `AS::Callback`Godfrey Chan2014-12-121-1/+37
| | | | | | | | | | | | | I'm not sure what's the use case for this, but apparently it broke some apps. Since it was not the intended result from #16210 I fixed it to not raise an exception anymore. However, I didn't add documentation for it because I don't know if this should be officially supported without knowing how it's meant to be used. In general, validations should be side-effect-free (other than adding to the error message to `@errors`). Order-dependent validations seems like a bad idea. Fixes #18002
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Added test for exception message for validate methodPrathamesh Sonpatki2014-09-231-1/+3
| | | | - Test case for https://github.com/rails/rails/pull/16851
* [ci skip] make assert messages consistentankit19102014-08-251-2/+2
|
* Merge pull request #15959 from aditya-kapoor/remove-unneeded-casesRafael Mendonça França2014-07-291-13/+17
|\ | | | | remove unneeded test model for ActiveModel test cases.
| * remove unneeded test model for ActiveModel test cases.Aditya Kapoor2014-06-281-13/+17
| |
* | Merge pull request #16210 from sonnym/assert_valid_keys_in_validateMatthew Draper2014-07-181-0/+7
|\ \ | |/ |/| | | Check for valid options in validate method
| * check for valid options in validate methodsonnym2014-07-171-0/+6
|/ | | | | | | | | | | This change prevents a certain class of user error which results when mistakenly using the `validate` class method instead of the `validates` class method. Only apply when all arguments are symbols, because some validations use the `validate` method and pass in additional options, namely the `LenghValidator` via the `ActiveMode::Validations::validates_with` method.
* remove depricated Validatior#setupKuldeep Aggarwal2014-06-101-21/+0
|
* ActiveRecord/ActiveModel '#validate' alias for 'valid?'Henrik Nyh2014-03-271-0/+9
| | | | | | | | It's unintuitive to call '#valid?' when you want to run validations but don't care about the return value. The alias in ActiveRecord isn't strictly necessary (the ActiveModel alias is still in effect), but it clarifies.
* Completely remove potential global state leaks in ActiveModel tests.Zuhao Wan2014-03-111-0/+2
| | | | ActiveModel tests can now be run in random order.
* Fix some validators when used on model instanceEric Hutzelman2014-02-261-1/+2
| | | | | | | | Now that Validator #setup is called from the initializer, we need a reference to the model's class to be passed in to allow the validators to continue functioning when used at the instance level. Closes #14134.
* Use the new clear_validators! api to reset validators in testsCarlos Antonio da Silva2014-01-271-8/+1
|
* deprecate Validator#setup (to get rid of a respond_to call). validators do ↵Nick Sutterer2013-05-231-0/+21
| | | | their setup in their constructor now.
* callbacks are wrapped with lambdasAaron Patterson2013-05-101-1/+1
|
* 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' ).
* fix some typos found in activemodelVipul A M2013-03-181-2/+2
|
* Small typos here and there.Vipul A M2013-03-151-2/+2
|
* Revert "Merge pull request #7826 from sikachu/master-validators-kind"Rafael Mendonça França2012-10-021-8/+0
| | | | | | | | | | | | | | | | This reverts commit 4e9f53f9736544f070e75e516c71137b7eb49a7a, reversing changes made to 6b802cdb4f5b84e1bf49aaeb0e994b3be6028af9. Revert "Don't use tap in this case." This reverts commit 454d820bf0a18fe1db4c55b0145197d70fef1f82. Reason: Is not a good idea to add options to this method since we can do the same thing using method composition. Person.validators_on(:name).select { |v| v.kind == :presence } Also it avoids to change the method again to add more options.
* Make `.validators_on` accept `:kind` optionPrem Sichanugrist2012-10-021-0/+8
| | | | | This will filter out the validators on a particular attribute based on its kind.
* AM::Validation#validates: ability to pass custom exception to `:strict` optionBogdan Gusiev2012-08-061-0/+9
|
* Don't enable validations when passing false hash values to ActiveModel.validatesSteve Purcell2012-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing a falsey option value for a validator currently causes that validator to be enabled, just like "true": ActiveModel.validates :foo, :presence => false This is rather counterintuitive, and makes it inconvenient to wrap `validates` in methods which may conditionally enable different validators. As an example, one is currently forced to write: def has_slug(source_field, options={:unique => true}) slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? } before_validation slugger validations = { :presence => true, :slug => true } if options[:unique] validations[:uniqueness] = true end validates :slug, validations end because the following reasonable-looking alternative fails to work as expected: def has_slug(source_field, options={:unique => true}) slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? } before_validation slugger validates :slug, :presence => true, :slug => true, :uniqueness => options[:unique] end (This commit includes a test, and all activemodel and activerecord tests pass as before.)
* Kill whitespaces :scissors:Carlos Antonio da Silva2012-05-151-1/+1
|
* clean the erros if an object that includes validations errors is duped. ↵Angelo Capilleri2012-05-131-0/+15
| | | | Fixes #5953
* replacing ordered hash to ruby hashprasath2012-02-081-1/+1
|
* Generate strict validation error messages with attribute nameCarlos Antonio da Silva2012-02-011-3/+12
|
* Removed unwanted intializer and replaced with ruby default collect methodprasath2012-01-271-2/+1
|
* validates method should not change options argumentdreamfall2012-01-171-0/+6
|
* Implemented strict validation conceptBogdan Gusiev2011-08-171-0/+33
| | | | | | | In order to deliver debug information to dev team instead of display error message to end user Implemented strict validation concept that suppose to define validation that always raise exception when fails
* :if should not fire on validations when not in context with :onAditya Sanghi2011-04-291-0/+14
|
* Find all validators for multiple attributesCarl Lerche2011-02-051-0/+18
|
* Tests and docs which explain the use of validate with a block and without ↵Santiago Pastorino2010-12-191-1/+9
| | | | arguments
* ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json ↵Thilo Utke2010-12-011-2/+2
| | | | | | serialization to properly handle multiple errors per attribute [#5615 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Remove deprecations in ActiveModel.José Valim2010-08-291-36/+0
|
* after_validation should be called irrespective of the result of validation.Neeraj Singh2010-08-201-0/+2
| | | | | | | | I confirmed that this is the behavior on 2.3.x . [5419 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-1/+1
| | | | 's/[ \t]*$//' -i {} \;)
* ActiveModel::Errors json serialization to work as Rails 3b4 [#5254 ↵Alex Le2010-08-021-3/+5
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>