aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/validations/length_validation_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Module#{attr,attr_accessor,attr_reader,attr_writer} become public since Ruby 2.5Ryuta Kamizono2018-12-211-1/+1
| | | | https://bugs.ruby-lang.org/issues/14132
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-4/+4
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Deprecate update_attributes and update_attributes!Eddie Lebow2018-02-171-1/+1
| | | | Closes #31998
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-13/+13
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-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
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-13/+13
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Revert changes to validations from PR #18612eileencodes2016-02-231-14/+0
| | | | | | | | | | | | | | | | | | | | In order to fix issue #17621 we added a check to validations that determined if a record should be validated. Based on the existing tests and behavior we wanted we determined the best way to do that was by checking if `!record.peristed? || record.changed? || record.marked_for_destruction?` This change didn't make it into a release until now. When #23790 was opened we realized that `valid?` and `invalid?` were broken and did not work on persisted records because of the `!record.persisted?`. While there is still a bug that #17621 brought up, this change was too drastic and should not be a RC blocker. I will work on fixing this so that we don't break `valid?` but also aren't validating parent records through child records if that parent record is validate false. This change removes the code changes to validate and the corresponding tests. It adds tests for two of the bugs found since Rails 5 beta2 release. Fixes #17621
* Match test name to test (typo)Ian Fleeton2016-02-211-1/+1
|
* Always validate record if validating a virtual attributeeileencodes2016-02-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #23645 When you're using an `attr_accessor` for a record instead of an attribute in the database there's no way for the record to know if it has `changed?` unless you tell it `attribute_will_change!("attribute")`. The change made in 27aa4dd updated validations to check if a record was `changed?` or `marked_for_destruction?` or not `persisted?`. It did not take into account virtual attributes that do not affect the model's dirty status. The only way to fix this is to always validate the record if the attribute does not belong to the set of attributes the record expects (in `record.attributes`) because virtual attributes will not be in that hash. I think we should consider deprecating this particular behavior in the future and requiring that the user mark the record dirty by noting that the virtual attribute will change. Unfortunately this isn't easy because we have no way of knowing that you did the "right thing" in your application by marking it dirty and will get the deprecation warning even if you are doing the correct thing. For now this restores expected behavior when using a virtual attribute by always validating the record, as well as adds tests for this case. I was going to add the `!record.attributes.include?(attribute)` to the `should_validate?` method but `uniqueness` cannot validate a virtual attribute with nothing to hold on to the attribute. Because of this `should_validate?` was about to become a very messy method so I decided to split them up so we can handle it specifically for each case.
* File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-1/+0
|
* replace `repair_validations` with a disposable subclass.Yves Senn2015-03-061-32/+33
|
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Fix validations on child record when record parent has validate: falseeileencodes2015-02-011-3/+16
| | | | | | | | | | | | | | Fixes #17621. This 5 year old (or older) issue causes validations to fire when a parent record has `validate: false` option and a child record is saved. It's not the responsibility of the model to validate an associated object unless the object was created or modified by the parent. Clean up tests related to validations `assert_nothing_raised` is not benefiting us in these tests Corrected spelling of "respects" It's better to use `assert_not_operator` over `assert !r.valid`
* AR specific length validator to respect `marked_for_destruction`.Yves Senn2014-12-301-0/+18
| | | | | | | | Closes #7247. Conflicts: activerecord/CHANGELOG.md activerecord/test/models/owner.rb
* move AR length validation tests into separate test-case.Yves Senn2014-04-241-0/+47
Conflicts: activerecord/test/cases/validations/association_validation_test.rb