aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/join_model_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-1/+1
| | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-1/+1
| | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* Respect new records for `CollectionProxy#uniq`Ryuta Kamizono2016-11-131-1/+1
| | | | | | | | | | | | | Currently if `CollectionProxy` has more than one new record, `CollectionProxy#uniq` result is incorrect. And `CollectionProxy#uniq` was aliased to `distinct` in a1bb6c8b06db. But the `uniq` method and the `SELECT DISTINCT` method are different methods. The doc in `CollectionProxy` is for the `SELECT DISTINCT` method, not for the `uniq` method. Therefore, reverting the alias in `CollectionProxy` to fix the inconsistency and to have the both methods.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-14/+14
|
* improve error message when include assertions failMichael Grosser2016-09-161-13/+13
| | | | | | 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-8/+8
| | | | | | | | 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
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-51/+51
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-64/+64
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Merge pull request #22518 from ↵Arthur Nogueira Neves2016-03-181-0/+17
|\ | | | | | | | | RochesterinNYC/better-error-message-for-includes-relations-missing Improve error message for missing relations for includes and eager_load
| * Improve clarity of error message for missing includes and eager_loadJames Wen2016-01-281-0/+17
| | | | | | | | relations
* | Respect through association scopes when used with polymorphicSean Griffin2016-02-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | When the `source_type` option is passed to a has_many through, the resulting `Reflection` will be an instance of `PolymorphicReflection` and not `ThroughReflection`, meaning that it will ignore the scopes that it needs to apply from the through reflections. This adds an additional delegation call to remedy this. I've been finding the reflection code completely impenetrable lately, it could use some major love. Fixes #22726
* | remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-1/+1
|/
* Silence deprecation warning from force reloadPrem Sichanugrist2015-07-161-15/+17
| | | | | | | | | | | | We deprecate the support for passing an argument to force reload in 6eae366d0d2e5d5211eeaf955f56bd1dc6836758. That led to several deprecation warning when running Active Record test suite. This commit silence the warnings by properly calling `#reload` on the association proxy or on the association object instead. However, there are several places that `ActiveSupport::Deprecation.silence` are used as those tests actually tests the force reload functionality and will be removed once `master` is targeted next minor release (5.1).
* deprecate `Relation#uniq` use `Relation#distinct` instead.Yves Senn2015-05-261-4/+4
| | | | | | | | | See #9683 for the reasons we switched to `distinct`. Here is the discussion that triggered the actual deprecation #20198. `uniq`, `uniq!` and `uniq_value` are still around. They will be removed in the next minor release after Rails 5.
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Fix "nonexistent" typo in testsMelissa Xie2014-12-021-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+3
|
* Deprecate automatic counter caches on has_many :throughSean Griffin2014-06-261-12/+13
| | | | | | | | | | | Reliant on https://github.com/rails/rails/pull/15747 but pulled to a separate PR to reduce noise. `has_many :through` associations have the undocumented behavior of automatically detecting counter caches. However, the way in which it does so is inconsistent with counter caches everywhere else, and doesn't actually work consistently. As with normal `has_many` associations, the user should specify the counter cache on the `belongs_to`, if they'd like it updated.
* Fix some typos in AR- CHANGELOG, tests, method doc. fixedVipul A M2013-03-201-1/+1
|
* rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.Yves Senn2013-03-151-2/+2
| | | | | | | | The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our Relation API is close to SQL terms I renamed `#uniq` to `#distinct`. There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue to work. I also updated the documentation to promote the use of `#distinct`.
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|
* deprecate `assert_blank` and `assert_present`.Yves Senn2013-01-051-2/+2
| | | | | They don't add any benefits over `assert object.blank?` and `assert object.present?`
* Fix has_many assocation w/select load after createErnie Miller2012-10-051-0/+8
| | | | | | | | | | | | | | If you create a new record via a collection association proxy that has not loaded its target, and which selects additional attributes through the association, then when the proxy loads its target, it will inadvertently trigger an ActiveModel::MissingAttributeError during attribute writing when CollectionAssociation#merge_target_lists attempts to do its thing, since the newly loaded records will possess attributes the created record does not. This error also raises a bogus/confusing deprecation warning when accessing the association in Rails 3.2.x, so cherry-pick would be appreciated!
* Use method compilation for association methodsJon Leighton2012-08-101-1/+1
| | | | | | | | | Method compilation provides better performance and I think the code comes out cleaner as well. A knock on effect is that methods that get redefined produce warnings. I think this is a good thing. I had to deal with a bunch of warnings coming from our tests, though.
* removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-061-2/+2
| | | | | | | | | | | | | | | | | | | by Active Support) Selecting which key extensions to include in active_support/rails made apparent the systematic usage of Object#in? in the code base. After some discussion in https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d we decided to remove it and use plain Ruby, which seems enough for this particular idiom. In this commit the refactor has been made case by case. Sometimes include? is the natural alternative, others a simple || is the way you actually spell the condition in your head, others a case statement seems more appropriate. I have chosen the one I liked the most in each case.
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-27/+27
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* ActiveRecord::Base.all returns a Relation.Jon Leighton2012-07-271-17/+17
| | | | | | | | | | | Previously it returned an Array. If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This is more explicit. In most cases this should not break existing code, since Relations use method_missing to delegate unknown methods to #to_a anyway.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-6/+6
| | | | Closes #1190
* Add tests to delete by fixnum or string id with has many through associationsFrancesco Rodriguez2012-05-281-0/+20
|
* Fix failing build related to change in CollectionAssociation#deleteCarlos Antonio da Silva2012-05-291-1/+1
| | | | Merge commit 6f1d9d00ffd9d411b2bd488da4eb92b7e2fd972e
* quarantine deprecated testsJon Leighton2012-05-181-9/+0
|
* CollectionProxy < RelationJon Leighton2012-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | This helps bring the interfaces of CollectionProxy and Relation closer together, and reduces the delegation backflips we need to perform. For example, first_or_create is defined thus: class ActiveRecord::Relation def first_or_create(...) first || create(...) end end If CollectionProxy < Relation, then post.comments.first_or_create will hit the association's #create method which will actually add the new record to the association, just as post.comments.create would. With the previous delegation, post.comments.first_or_create expands to post.comments.scoped.first_or_create, where post.comments.scoped has no knowledge of the association.
* remove deprecated callsJon Leighton2012-04-271-4/+4
|
* find and replace deprecated keysJon Leighton2012-04-271-15/+15
|
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-23/+23
| | | | things
* remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-7/+7
|
* remove deprecate #calculate callsJon Leighton2012-04-261-1/+1
|
* fix #scoped deprecationsJon Leighton2012-04-261-3/+3
|
* remove tests for #with_scope (it's now deprecated)Jon Leighton2012-04-251-8/+0
|
* fix testsJon Leighton2012-04-131-1/+1
|
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-1/+1
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-2/+2
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-2/+2
|
* Deprecate set_table_name in favour of self.table_name= or defining your own ↵Jon Leighton2011-11-291-1/+1
| | | | method.
* Do not hardcode :id as it was ignored by mass assignment filterRaimonds Simanovskis2011-06-081-2/+2
| | | As a result test was failing on Oracle where ids are assigned by default from 1000
* Allow polymorphic has_one to work when the association is set before the ↵Jon Leighton2011-06-081-0/+11
| | | | owner has been saved. Fixes #1524.