aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Do not test, document or use a private API methodRafael Mendonça França2015-02-201-22/+0
| | | | These methods are nodoc so we should not document them.
* Merge pull request #16989 from Empact/reload-cache-clearRafael Mendonça França2015-02-201-2/+2
|\ | | | | | | Isolate access to @associations_cache and @aggregations_cache to the Associations and Aggregations modules, respectively.
| * Isolate access to @associations_cache and @aggregations cache to the ↵Ben Woosley2014-09-281-2/+2
| | | | | | | | | | | | | | | | Associations and Aggregations modules, respectively. This includes replacing the `association_cache` accessor with a more limited `association_cached?` accessor and making `clear_association_cache` and `clear_aggregation_cache` private.
* | `WhereClause#predicates` does not need to be publicSean Griffin2015-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | The only place it was accessed was in tests. Many of them have another way that they can test their behavior, that doesn't involve reaching into internals as far as they did. `AssociationScopeTest` is testing a situation where the where clause would have one bind param per predicate, so it can just ignore the predicates entirely. The where chain test was primarly duplicating the logic tested on `WhereClause` directly, so I instead just make sure it calls the appropriate method which is fully tested in isolation.
* | Go through normal `where` logic in `AssociationScope`Sean Griffin2015-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This removes the need to duplicate much of the logic in `WhereClause` and `PredicateBuilder`, simplifies the code, removes the need for the connection adapter to be continuously passed around, and removes one place that cares about the internal representation of `bind_values` Part of the larger refactoring to change how binds are represented internally [Sean Griffin & anthonynavarre]
* | Remove all references to `where_values` in testsSean Griffin2015-01-251-1/+1
| |
* | Ensure `first!` and friends work on loaded associationsSean Griffin2014-12-291-0/+5
| | | | | | | | Fixes #18237
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
| |
* | Build fix when running in isolationArun Agrawal2014-11-141-0/+1
|/ | | | | `Computer` class needs to be require See #17217 for more details
* Allow included modules to override association methods.Yves Senn2014-09-091-0/+14
| | | | | | | | | | Closes #16684. This is achieved by always generating `GeneratedAssociationMethods` when `ActiveRecord::Base` is subclassed. When some of the included modules of `ActiveRecord::Base` were reordered this behavior was broken as `Core#initialize_generated_modules` was no longer called. Meaning that the module was generated on first access.
* always reorder bind parameters. fixes #15920Aaron Patterson2014-09-041-1/+8
|
* Calling reset on a collection association should unload the assocationKelsey Schlarman2014-01-211-0/+9
| | | | Need to define #reset on CollectionProxy.
* do is_a? tests on assignment so runtime is fasterAaron Patterson2013-07-311-2/+2
|
* Fix typo in test name and documentationVipul A M2013-05-201-1/+1
|
* Set the inverse when association queries are refinedJon Leighton2013-05-101-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Suppose Man has_many interests, and inverse_of is used. Man.first.interests.first.man will correctly execute two queries, avoiding the need for a third query when Interest#man is called. This is because CollectionAssociation#first calls set_inverse_instance. However Man.first.interests.where("1=1").first.man will execute three queries, even though this is obviously a subset of the records in the association. This is because calling where("1=1") spawns a new Relation object from the CollectionProxy object, and the Relation has no knowledge of the association, so it cannot set the inverse instance. This commit solves the problem by making relations spawned from CollectionProxies return a new Relation subclass called AssociationRelation, which does know about associations. Records loaded from this class will get the inverse instance set properly. Fixes #5717. Live commit from La Conf! :sparkles:
* Removed space and unused classAnupam Choudhury2013-04-061-1/+0
|
* Cache the association proxy objectJon Leighton2013-03-151-0/+5
| | | | | | | | This reimplements the behaviour of Rails 3, as I couldn't see why we shouldn't cache the object, and @alindeman had a good use case for caching it: https://github.com/rails/rails/commit/c86a32d7451c5d901620ac58630460915292f88b#commitcomment-2784312
* MOAR cleanups.Vipul A M2013-03-141-1/+1
|
* deal with `#append` and `#prepend` on association collections.Yves Senn2013-03-011-1/+13
| | | | | | | | | | | Closes #7364. Collection associations behave similar to Arrays. However there is no way to prepend records. And to append one should use `<<`. Before this patch `#append` and `#prepend` did not add the record to the loaded association. `#append` now behaves like `<<` and `#prepend` is not defined.
* Ensure that associations have a symbol argument.Steve Klabnik2012-11-281-0/+8
| | | | Fixes #7418.
* Add CollectionProxy#scopeJon Leighton2012-08-011-0/+7
| | | | | | | | | | | | | | | | This can be used to get a Relation from an association. Previously we had a #scoped method, but we're deprecating that for AR::Base, so it doesn't make sense to have it here. This was requested by DHH, to facilitate code like this: Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do @topics = @project.topics.scope @todolists = @project.todolists.scope @attachments = @project.attachments.scope @documents = @project.documents.scope end
* Deprecate Relation#all.Jon Leighton2012-07-271-1/+1
| | | | | | It has been moved to active_record_deprecated_finders. Use #to_a instead.
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-5/+5
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-2/+2
| | | | Closes #1190
* find and replace deprecated keysJon Leighton2012-04-271-2/+2
|
* allow AssociationProxy#scoped to take options so that API is the same as ↵Jon Leighton2012-04-271-0/+4
| | | | Base#scoped
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-2/+2
| | | | things
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-1/+6
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-1/+1
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-1/+1
|
* don't change class definition in test caseJosh Susser2011-11-291-6/+0
|
* add test for super-ing to association methodsJosh Susser2011-11-151-2/+12
|
* association methods are now generated in modulesJosh Susser2011-11-151-0/+12
| | | | | | | | | | Instead of generating association methods directly in the model class, they are generated in an anonymous module which is then included in the model class. There is one such module for each association. The only subtlety is that the generated_attributes_methods module (from ActiveModel) must be forced to be included before association methods are created so that attribute methods will not shadow association methods.
* Add a proxy_association method to association proxies, which can be called ↵Jon Leighton2011-07-271-0/+5
| | | | by association extensions to access information about the association. This replaces proxy_owner etc with proxy_association.owner.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* removed deprecated methods, and related tests, from ActiveRecordJosh Kalderimis2011-05-251-12/+0
|
* Implement proxy_owner, proxy_target and proxy_reflection methods on ↵Jon Leighton2011-05-191-0/+12
| | | | CollectionProxy with deprecations. Fixes #1148.
* minor cleaningVishnu Atrai2011-05-101-1/+1
|
* Added new #update_column method.Sebastian Martinez2011-03-271-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-2/+2
| | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Remove test which was broken on 1.8. This test is now irrelevant since ↵Jon Leighton2011-02-181-8/+0
| | | | singular associations no longer return a proxy object.
* Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-181-36/+0
| | | | manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
* class inheritable attributes is used no more! all internal use of class ↵Josh Kalderimis2010-11-201-4/+4
| | | | | | inheritable has been changed to class_attribute. class inheritable attributes has been deprecated. Signed-off-by: José Valim <jose.valim@gmail.com>
* removing many unused variablesAaron Patterson2010-11-161-1/+1
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-3/+3
| | | | 's/[ \t]*$//' -i {} \;)
* Making Active Record base_test.rb thinner by moving testsNeeraj Singh2010-08-031-0/+22
| | | | | | | | | | | | to relevant files. Number of assertions before refactoring: 2391 tests, 7579 assertions, 0 failures, 0 errors Number of assertions after refactoring: 2391 tests, 7579 assertions, 0 failures, 0 errors Signed-off-by: José Valim <jose.valim@gmail.com>
* Eager loading an association should not change the count of childrenNeeraj Singh2010-08-021-0/+13
| | | | | | [#4971 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* removing unused models from testsSubba Rao Pasupuleti2010-07-211-11/+0
| | | | | | [#5153 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>