aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
* add missing fixtures fileAaron Patterson2013-08-301-1/+2
|
* make sure there are actually some categories when running the testAaron Patterson2013-08-291-0/+1
|
* pk should not be required for hm:t associationsAaron Patterson2013-08-291-0/+7
|
* query the association rather than send the method for the association nameAaron Patterson2013-08-271-6/+4
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-08-171-1/+1
|\ | | | | | | | | | | | | | | Conflicts: actionview/README.rdoc activerecord/lib/active_record/migration.rb guides/source/development_dependencies_install.md guides/source/getting_started.md
| * Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-1/+1
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* | Fixing multi-word automatic inverse detection.wangjohn2013-08-151-0/+14
| | | | | | | | | | Currently, ActiveRecord models with multiple words cannot have their inverse associations detected automatically.
* | using assert_not instead of refuteRajarshi Das2013-08-131-1/+1
| |
* | add a test for concat on hm:t associationsAaron Patterson2013-08-021-0/+7
| |
* | association builder classes no longer need the modelAaron Patterson2013-08-011-1/+1
| | | | | | | | | | decouple the builder classes from the model. Builder objects should be easier to reuse now.
* | no need to define the constant twiceAaron Patterson2013-08-011-1/+0
| |
* | assert that constants have been set rather than the namesAaron Patterson2013-08-011-6/+8
| |
* | Merge pull request #11668 from neerajdotname/make_test_order_independent_2Rafael Mendonça França2013-07-301-1/+3
|\ \ | | | | | | Make test order independent
| * | assert_no_queries should ignore certain sqlsNeeraj Singh2013-07-301-1/+3
| | | | | | | | | | | | | | | postgresql test if randomly executed then executes "SHOW max_identifier_length". Hence the need to ignore certain predefined sqls that deal with system calls.
* | | Revert change on ActiveRecord::Relation#order method that prepends newRafael Mendonça França2013-07-292-4/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | order on the old ones The previous behavior added a major backward incompatibility since it impossible to have a upgrade path without major changes on the application code. We are taking the most conservative path to be consistent with the idea of having a smoother upgrade on Rails 4. We are reverting the behavior for what was in Rails 3.x and, if needed, we will implement a new API to prepend the order clauses in Rails 4.1.
* | Clear class ivar before testingAkira Matsuda2013-07-291-0/+2
| |
* | Unneeded assertionAkira Matsuda2013-07-291-1/+1
| |
* | make test not depend on orderNeeraj Singh2013-07-281-0/+1
|/ | | | | | | `NestedThroughAssociationsTest` adds records to `member_details` table. When test performs `@member_details[0]` then the order of record is not guaranteed. Hence it is best to start with a clean slate by deleting unwanted records.
* used flat_map instead of map.flattenKarunakar (Ruby)2013-07-251-1/+1
|
* Make sure that a joins Relation can be merged with has_many :through + ↵Akira Matsuda2013-07-101-0/+6
| | | | | | association proxy Closes #11248.
* Remove redundant test about `push_with_attributes` removal.Vipul A M2013-07-091-7/+0
|
* #11288: Removed duplicated touchingPaul Nikitochkin2013-07-051-1/+42
| | | | | | if belongs to model with touch option on touch Closes #11288
* Cleanup belongs to testsPaul Nikitochkin2013-07-051-2/+1
| | | | simplified logic to calculate number of queries by using assert_queries
* Dropped deprecated option `:restrict` for `:dependent` in associationsNeeraj Singh2013-07-032-31/+0
|
* Removed support for deprecated `delete_sql` in associations.Neeraj Singh2013-07-031-25/+0
|
* Removed support for deprecated `finder_sql` in associations.Neeraj Singh2013-07-022-140/+0
|
* Removed support for deprecated `counter_sql`Neeraj Singh2013-07-022-45/+0
|
* Merge pull request #10604 from ↵Rafael Mendonça França2013-07-012-2/+59
|\ | | | | | | | | | | | | | | | | neerajdotname/delete_all_should_not_call_callbacks Do not invoke callbacks when delete_all is called Conflicts: activerecord/CHANGELOG.md
| * Do not invoke callbacks when delete_all is calledNeeraj Singh2013-06-302-2/+59
| | | | | | | | | | | | | | | | | | | | | | Method `delete_all` should not be invoking callbacks and this feature was deprecated in Rails 4.0. This is being removed. `delete_all` will continue to honor the `:dependent` option. However if `:dependent` value is `:destroy` then the default deletion strategy for that collection will be applied. User can also force a deletion strategy by passing parameter to `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`
* | Removed deprecated options for assocationsNeeraj Singh2013-07-022-22/+0
|/ | | | | Deprecated options `delete_sql`, `insert_sql`, `finder_sql` and `counter_sql` have been deleted.
* remove deprecated implicit join references.Yves Senn2013-06-291-15/+5
|
* Apply default scope when joining associations.Jon Leighton2013-06-281-0/+8
| | | | | | | | | | | | | | | | | | | For example: class Post < ActiveRecord::Base default_scope -> { where published: true } end class Comment belongs_to :post end When calling `Comment.join(:post)`, we expect to receive only comments on published posts, since that is the default scope for posts. Before this change, the default scope from `Post` was not applied, so we'd get comments on unpublished posts.
* Remove depreacted findersŁukasz Strzałkowski2013-06-281-2/+2
| | | | They were deprecated in 4.0, planned to remove in 4.1
* Fix `another_contract` not being used warningVipul A M2013-06-241-1/+1
|
* test-case to prevent regressions described in #10901.Jared Armstrong2013-06-241-0/+27
|
* test-case to prevent regressions on `Association#build` with an Array.Yves Senn2013-06-221-0/+10
| | | | Closes #11026
* do not load all child records for inverse caseNeeraj Singh2013-06-211-0/+8
| | | | | | | | | | | | | | currently `post.comments.find(Comment.first.id)` would load all comments for the given post to set the inverse association. This has a huge performance penalty. Because if post has 100k records and all these 100k records would be loaded in memory even though the comment id was supplied. Fix is to use in-memory records only if loaded? is true. Otherwise load the records using full sql. Fixes #10509
* fix bad test by making number that fits for integerNeeraj Singh2013-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR https://github.com/rails/rails/pull/10566 had to be reverted because after applying the fix test "test_raise_record_not_found_error_when_invalid_ids_are_passed" started failing. In this test invalid_id is being assigned a really large number which was causing following failure when PR #10566 was applied. ``` RangeError: bignum too big to convert into `long long' SELECT `interests`.* FROM `interests` WHERE `interests`.`man_id` = ? AND `interests`.`id` = ? LIMIT 1 [["man_id", 970345987], ["id", 2394823094892348920348523452345]] ``` This test is not failing in master because when test code `man.interests.find(invalid_id)` is executed then interests are fully loaded in memory and no database query is executed. After PR #10566 was merged then test code `man.interests.find(invalid_id)` started executing sql query and hence the error. In case someone is wondering why the second part of query is not failing, then that's because the actual query does not require any variable substituation where the number is large. In that case the sql generate is following. ``` SELECT `interests`.* FROM `interests` WHERE `interests`.`man_id` = ? AND `interests`.`id` IN (8432342, 2390102913, 2453245234523452) [["man_id", 970345987]] ```
* Revert "Merge pull request #10566 from neerajdotname/10509d"Jon Leighton2013-06-191-8/+0
| | | | | | | | | | This reverts commit 2b817a5e89ac0e7aeb894a40ae7151a0cf3cef16, reversing changes made to 353a398bee68c5ea99d76ac7601de0a5fef6f4a5. Conflicts: activerecord/CHANGELOG.md Reason: the build broke
* do not load all child records for inverse caseNeeraj Singh2013-06-191-0/+8
| | | | | | | | | | | | | | currently `post.comments.find(Comment.first.id)` would load all comments for the given post to set the inverse association. This has a huge performance penalty. Because if post has 100k records and all these 100k records would be loaded in memory even though the comment id was supplied. Fix is to use in-memory records only if loaded? is true. Otherwise load the records using full sql. Fixes #10509
* Merge pull request #10987 from senny/10979_association_include_returns_trueXavier Noria2013-06-181-11/+11
|\ | | | | `CollectionProxy#include?` returns `true` and `false` as documented.
| * `CollectionProxy#include?` returns `true` and `false` as documented.Yves Senn2013-06-181-11/+11
| |
* | Merge pull request #10533 from vipulnsward/fix_testRafael Mendonça França2013-06-151-1/+2
|\ \ | |/ |/| Fix test, addresss => address
| * Make test name descriptive and add reference to original regression commitVipul A M2013-06-151-1/+2
| |
* | Merge pull request #10824 from vipulnsward/wonderfulGuillermo Iguaran2013-06-021-1/+1
|\ \ | | | | | | wonderfull => wonderful
| * | wonderfull => wonderfulVipul A M2013-06-021-1/+1
| | |
* | | Remove #sum with a block was deprecated.kennyj2013-06-011-6/+0
|/ /
* | `implicit_readonly` is being removed in favor of calling `readonly` explicitlyYves Senn2013-05-271-4/+4
| |
* | Fix the `:primary_key` option for `has_many` associations.Yves Senn2013-05-231-0/+8
|/ | | | | | | | | | | | | | | | | When removing records from a `has_many` association it used the `primary_key` defined on the association. Our test suite didn't fail because on all occurences of `:primary_key`, the specified column was available in both tables. This prevented the code from raising an exception but it still behaved badly. I added a test-case to prevent regressions that failed with: ``` 1) Error: HasManyAssociationsTest#test_has_many_assignment_with_custom_primary_key: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: essays.first_name: UPDATE "essays" SET "writer_id" = NULL WHERE "essays"."writer_id" = ? AND "essays"."first_name" IS NULL ```
* Created a method to automatically find inverse associations and cachewangjohn2013-05-071-0/+82
| | | | | | the results. Added tests to check to make sure that inverse associations are automatically found when has_many, has_one, or belongs_to associations are defined.