aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/topic.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Revert "Remove unused callbacks in the `Topic` model"Ryuta Kamizono2019-04-101-0/+4
| | | | | | | | This reverts commit b33ccaa6c335e2ce482c9de1aa05e4a612aa84bc. That isn't hit by `git grep`, but actually used in meta-programming... https://github.com/rails/rails/blob/b33ccaa6c335e2ce482c9de1aa05e4a612aa84bc/activerecord/test/cases/transactions_test.rb#L1020-L1028
* Remove unused callbacks in the `Topic` modelRyuta Kamizono2019-04-101-4/+0
|
* Use dedicated `Topic` model for `SerializedAttributeTest`Ryuta Kamizono2019-02-281-4/+0
| | | | | | | | | | | | | | | | | | This fixes both #34555 and #34738. Revert "Merge pull request #34900 from gmcgibbon/fix_test_find_only_some_columns" This reverts commit ff807f823b869d3491935a096183ee2bebd58e7b, reversing changes made to 9f1a07af0499080c9fd8815705a03a4c7e8fb506. Revert "Merge pull request #34560 from gmcgibbon/fix_decorate_leak_on_serial_attr_test" This reverts commit bd62389307e138ee0f274a9d62697567a3334ea0, reversing changes made to ec66c6a2fa4ee200259341a18ecd96310f388ba3. Revert "Fix unstable `test_serialized_attribute_works_under_concurrent_initial_access` test" This reverts commit 65c4b1b50df3fa59198de2d45d1f54b61ecc7864.
* Replaced usage of where.delete/destroy_all with delete/destroy_byAbhay Nikam2019-02-201-1/+1
|
* Revert "Chaining named scope is no longer leaking to class level querying ↵Ryuta Kamizono2019-02-141-3/+0
| | | | | | | | | methods" This reverts #32380, since this may cause that silently leaking information when people upgrade the app. We need deprecation first before making this.
* Chaining named scope is no longer leaking to class level querying methodsRyuta Kamizono2019-02-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Active Record uses `scoping` to delegate to named scopes from relations for propagating the chaining source scope. It was needed to restore the source scope in named scopes, but it was caused undesired behavior that pollute all class level querying methods. Example: ```ruby class Topic < ActiveRecord::Base scope :toplevel, -> { where(parent_id: nil) } scope :children, -> { where.not(parent_id: nil) } scope :has_children, -> { where(id: Topic.children.select(:parent_id)) } end # Works as expected. Topic.toplevel.where(id: Topic.children.select(:parent_id)) # Doesn't work due to leaking `toplevel` to `Topic.children`. Topic.toplevel.has_children ``` Since #29301, the receiver in named scopes has changed from the model class to the chaining source scope, so the polluting class level querying methods is no longer required for that purpose. Fixes #14003.
* Remove unused codebogdanvlviv2019-01-301-8/+0
| | | | | | | | - Remove `fragment_cache_key` helper declaration. It was removed in e70d3df7c9b05c129b0fdcca57f66eca316c5cfc - Remove `by_private_lifo`. It is unused since a7becf147afc85c354e5cfa519911a948d25fc4d
* Fix inspect with non-primary key id attributeEugene Kenny2018-11-061-0/+4
| | | | | | | | | | | The `read_attribute` method always returns the primary key when asked to read the `id` attribute, even if the primary key isn't named `id`, and even if another attribute named `id` exists. For the `inspect`, `attribute_for_inspect` and `pretty_print` methods, this behaviour is undesirable, as they're used to examine the internal state of the record. By using `_read_attribute` instead, we'll get the real value of the `id` attribute.
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Reuse existing model for testing duplicated children recordsRyuta Kamizono2018-06-071-1/+0
| | | | Follow up of #32952.
* Merge pull request #32952 from mechanicles/32940-fixRyuta Kamizono2018-05-291-0/+1
|\ | | | | | | Fix parent record should not get saved with duplicate children records
| * Fix parent record should not get saved with duplicate children recordsSantosh Wadghule2018-05-281-0/+1
| | | | | | | | - Fixes #32940
* | Fix that association's after_touch is not called with counter cacheRyuta Kamizono2018-05-271-0/+10
|/ | | | | | | | | | | | Since #31405, using `#increment!` with touch option instead of `#touch` to touch belongs_to association if counter cache is enabled. It caused the regression since `#increment!` won't invoke after_touch callbacks even if touch option is given. To fix the regression, make `#increment!` invokes after_touch callbacks if touch option is given. Fixes #31559. Fixes #32408.
* `becomes` should clear the mutation tracker which is created in ↵Ryuta Kamizono2018-05-111-1/+1
| | | | | | | | | | | | | | | | `after_initialize` `becomes` creates new object and copies attributes from the receiver. If new object has mutation tracker which is created in `after_initialize`, it should be cleared since it is for discarded attributes. But if the receiver doesn't have mutation tracker yet, it will not be cleared properly. It should be cleared regardless of whether the receiver has mutation tracker or not. Fixes #32867.
* Deprecate accessibility of private/protected class methods in named scopeRyuta Kamizono2018-03-301-2/+3
|
* Bring back private class methods accessibility in named scopeRyuta Kamizono2018-03-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The receiver in a scope was changed from `klass` to `relation` itself for all scopes (named scope, default_scope, and association scope) behaves consistently. In addition. Before 5.2, if both an AR model class and a Relation instance have same named methods (e.g. `arel_attribute`, `predicate_builder`, etc), named scope doesn't respect relation instance information. For example: ```ruby class Post < ActiveRecord::Base has_many :comments1, class_name: "RecentComment1" has_many :comments2, class_name: "RecentComment2" end class RecentComment1 < ActiveRecord::Base self.table_name = "comments" default_scope { where(arel_attribute(:created_at).gteq(2.weeks.ago)) } end class RecentComment2 < ActiveRecord::Base self.table_name = "comments" default_scope { recent_updated } scope :recent_updated, -> { where(arel_attribute(:updated_at).gteq(2.weeks.ago)) } end ``` If eager loading `Post.eager_load(:comments1, :comments2).to_a`, `:comments1` (default_scope) respects aliased table name, but `:comments2` (using named scope) may not work correctly since named scope doesn't respect relation instance information. See also 801ccab. But this is a breaking change between releases without deprecation. I decided to bring back private class methods accessibility in named scope. Fixes #31740. Fixes #32331.
* save attributes changed by callbacks after update_attributeMike Busch2017-12-221-0/+7
| | | | | | | | update_attribute previously stopped execution, before saving and before running callbacks, if the record's attributes hadn't changed. [The documentation](http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attribute) says that "Callbacks are invoked", which was not happening if the persisted attributes hadn't changed.
* 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
|
* Enable extending even if scope returns nilRyuta Kamizono2017-05-241-1/+1
|
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-241-1/+1
|
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | 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.
* modernizes hash syntax in activerecordXavier Noria2016-08-061-8/+8
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-7/+7
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Oracle TIMESTAMP sql type is associated with Rails `DateTime` type nowYasuo Honda2016-07-201-6/+0
| | | | | | - Refer https://github.com/rsim/oracle-enhanced/pull/845 Remove `set_date_columns` which has been deprecated in Oracle enhanced adapter - Refer https://github.com/rsim/oracle-enhanced/pull/869
* Deprecate passing conditions to AR::Relation destroy_all and delete_all methodsWojciech Wnętrzak2015-09-061-1/+1
|
* fix rails testsMehmet Emin İNAÇ2015-07-211-1/+1
|
* changed update counter to act on unscoped modelheruku2013-11-261-0/+4
|
* More unused associations in AR test modelsAkira Matsuda2013-09-101-1/+0
|
* Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-0/+1
| | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* More unused associations in AR test modelsAkira Matsuda2013-07-251-1/+0
|
* Describing the reason for defining BlankTopic#blank? which will never be calledAkira Matsuda2013-01-241-0/+1
|
* Revert "Unused methods, module, etc."Akira Matsuda2013-01-241-0/+9
| | | | | | This reverts commit 4e05bfb8e254c3360a3ca4a6cb332995314338fe. Reason: BlankTopic#blank? should not be removed to check that dynamic finder with a bang can find a model that responds to `blank?`
* Unused methods, module, etc.Akira Matsuda2013-01-241-9/+0
|
* Regression test for #7238Nikita Afanasenko2012-11-131-0/+6
|
* :counter_cache option for to support custom named counter caches. Closes #7993Yves Senn2012-11-041-0/+1
|
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-3/+3
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* made dynamic finders alias_attribute awareMaximilian Schneider2012-06-221-0/+2
| | | | | previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
* remove unnecessary test codeJon Leighton2012-04-271-5/+1
|
* remove deprecated scope stuffJon Leighton2012-04-261-13/+1
|
* extract deprecated codeJon Leighton2012-04-251-2/+2
|
* Deprecate eager-evaluated scopes.Jon Leighton2012-03-211-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use this: scope :red, where(color: 'red') default_scope where(color: 'red') Use this: scope :red, -> { where(color: 'red') } default_scope { where(color: 'red') } The former has numerous issues. It is a common newbie gotcha to do the following: scope :recent, where(published_at: Time.now - 2.weeks) Or a more subtle variant: scope :recent, -> { where(published_at: Time.now - 2.weeks) } scope :recent_red, recent.where(color: 'red') Eager scopes are also very complex to implement within Active Record, and there are still bugs. For example, the following does not do what you expect: scope :remove_conditions, except(:where) where(...).remove_conditions # => still has conditions
* Fixed after_initialize callbacks call on AR model #dupBogdan Gusiev2012-01-071-0/+5
|
* serialize fails on subclassAlvaro Bautista2011-12-231-0/+4
|
* call scope within unscoped to prevent duplication of where valuesSergey Nartimov2011-12-171-0/+2
|
* Make protected method public so we avoid method_missing.Jon Leighton2011-09-131-4/+5
|
* Revert "Deprecate defining scopes with a callable (lambda, proc, etc) via ↵Jon Leighton2011-04-171-15/+11
| | | | | | | | | | the scope class method. Just define a class method yourself instead." This reverts commit f0e198bfa1e3f9689e0cde1d194a44027fc90b3c. Conflicts: activerecord/test/models/post.rb
* Deprecate defining scopes with a callable (lambda, proc, etc) via the scope ↵Jon Leighton2011-04-121-11/+15
| | | | class method. Just define a class method yourself instead.