aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated support to passing a class to `:class_name` on associationsRafael Mendonça França2017-10-231-13/+0
|
* 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
|
* Remove a redundant test case of HABTM_associations_testKoichi ITO2017-05-311-13/+0
|
* Define path with __dir__bogdanvlviv2017-05-231-1/+1
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* Don't attempt to create a new record that was already created.Isaac Betesh2017-04-201-0/+20
| | | | Fixes #24032
* Correct spellingBenjamin Fleischer2017-02-051-2/+2
| | | | | | | ``` go get -u github.com/client9/misspell/cmd/misspell misspell -w -error -source=text . ```
* Deprecate reflection class name to accept a classKir Shatrov2017-01-091-2/+4
| | | | | | | | The idea of `class_name` as an option of reflection is that passing a string would allow us to lazy autoload the class. Using `belongs_to :client, class_name: Customer` is eagerloading models more than necessary and creating possible circular dependencies.
* Remove deprecated force reload argument in association readersRafael Mendonça França2016-12-291-6/+0
|
* 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-2/+2
|
* Merge PR #19759Arthur Neves2016-10-281-0/+13
|\ | | | | | | Fix for has_and_belongs_to_many & has_many_through associations
| * Fix for has_and_belongs_to_many & has_many_through associations while ↵Mehmet Emin İNAÇ2016-02-131-0/+13
| | | | | | | | | | | | | | | | partial_writes is false This will fix #19663 Also with this fix, active record does not fire unnecassary update queries while partial_writes is true
* | Fix HABTM associations join table resolver bug on constants and symbolsMehmet Emin İNAÇ2016-10-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Using Constant and symbol class_name option for associations are valid but raises exception on HABTM associations. There was a test case which tries to cover symbol class_name usage but doesn't cover correctly. Fixed both symbol usage and constant usage as well. These are all working as expected now; ``` has_and_belongs_to_many :foos, class_name: 'Foo' has_and_belongs_to_many :foos, class_name: :Foo has_and_belongs_to_many :foos, class_name: Foo ``` Closes #23767
* | improve error message when include assertions failMichael Grosser2016-09-161-10/+10
| | | | | | | | | | | | 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-4/+4
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | | | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* | remove redundant curlies from hash argumentsXavier Noria2016-08-061-4/+2
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-46/+46
| |
* | applies new string literal convention in activerecord/testXavier Noria2016-08-061-82/+82
| | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | Merge pull request #25767 from ↵Rafael França2016-07-271-0/+6
|\ \ | | | | | | | | | | | | kamipo/association_name_is_the_same_as_join_table_name Correctly return `associated_table` when `associated_with?` is true
| * | Correctly return `associated_table` when `associated_with?` is trueRyuta Kamizono2016-07-101-0/+6
| | | | | | | | | | | | | | | | | | | | | `AssociationQueryHandler` requires `association` initialized `TableMetadata` even if `table_name == arel_table.name`. Fixes #25689.
* | | Move the warning about composite primary key to `AttributeMethods::PrimaryKey`Ryuta Kamizono2016-07-021-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | Actually schema dumper/creation supports composite primary key (#21614). Therefore it should not show the warning about composite primary key in connection adapter. This change moves the warning to `AttributeMethods::PrimaryKey` and suppress the warning for habtm join table. Fixes #25388.
* | remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-1/+1
| |
* | fix typoLobsiinvok2016-02-201-1/+1
| |
* | eliminate warnings about multiple primary keys on habtm join tablesAaron Patterson2016-02-191-0/+13
|/ | | | | | | | habtm join tables commonly have two id columns and it's OK to make those two id columns a primary key. This commit eliminates the warnings for join tables that have this setup. ManageIQ/manageiq#6713
* Typos in AR testsAkira Matsuda2016-02-031-2/+2
|
* Ensure `has_and_belongs_to_many` works with `belongs_to_required_by_default`Sean Griffin2015-10-291-0/+6
| | | | | | | | | | | | | Before this commit, if `ActiveRecord::Base.belongs_to_required_by_default` is set to `true`, then creating a record through `has_and_belongs_to_many` fails with the cryptic error message `Left side must exist`. This is because `inverse_of` isn't working properly in this case, presumably since we're doing trickery with anonymous classes in the middle. Rather than following this rabbit hole to try and get `inverse_of` to work in a case that we know is not publicly supported, we can just turn off this validation to match the behavior of 4.2 and earlier.
* Merge pull request #18383 from ↵Rafael Mendonça França2015-10-271-0/+19
|\ | | | | | | | | | | scambra/habtm-with-where-includes-16032-for-master Includes HABTM returns correct size now
| * Includes HABTM returns correct size now. It's caused by the join dependencySergio Cambra2015-01-071-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | only instantiates one HABTM object because the join table hasn't a primary key. Updated commit from @bigxiang commit dbaa837 Fixes #16032. Examples: before: Project.first.salaried_developers.size # => 3 Project.includes(:salaried_developers).first.salaried_developers.size # => 1 after: Project.first.salaried_developers.size # => 3 Project.includes(:salaried_developers).first.salaried_developers.size # => 3
* | Include association's `unscope` when preloadingJimmy Bourassa2015-09-091-0/+21
| |
* | Removed mocha from Active Record Part 1Ronak Jangir2015-08-251-3/+4
| |
* | use correct DB connection for generated HABTM tableMatt Hanlon2015-08-071-0/+12
| |
* | Silence deprecation warning from force reloadPrem Sichanugrist2015-07-161-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | 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 force association reload by passing truePrem Sichanugrist2015-07-151-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to simplify the association API, as you can call `reload` on the association proxy or the parent object to get the same result. For collection association, you can call `#reload` on association proxy to force a reload: @user.posts.reload # Instead of @user.posts(true) For singular association, you can call `#reload` on the parent object to clear its association cache then call the association method: @user.reload.profile # Instead of @user.profile(true) Passing a truthy argument to force association to reload will be removed in Rails 5.1.
* | add `extend` option on `has_and_belongs_to_many`.keepcosmos2015-05-261-0/+15
| |
* | deprecate `Relation#uniq` use `Relation#distinct` instead.Yves Senn2015-05-261-5/+5
|/ | | | | | | | | 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.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Allow habtm class_name option to be consistent with other associationsshiksha2014-11-131-0/+10
|
* Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-1/+10
|
* Ignore SCHEMA queries in some habtm testsAkira Matsuda2014-08-141-4/+4
|
* Use a better test descriptionRafael Mendonça França2014-06-191-1/+1
|
* Fix has_and_belongs_to_many in a namespaced model pointing to a non ↵Rafael Mendonça França2014-06-191-0/+9
| | | | | | | | | | | | | | | namespaced model Now the following case will work fine class Tag < ActiveRecord::Base end class Publisher::Article < ActiveRecord::Base has_and_belongs_to_many :tags end Fixes #15761
* just use `assert`Aaron Patterson2014-06-021-1/+1
|
* Fix redefine a has_and_belongs_to_many inside inherited classArthur Neves2014-05-271-1/+15
| | | | | | | | | After ad7b5efb55bcc2e0ccd3e7f22a81e984df8676d1, which changed how has_an_belongs_to_many used to work, we start raising an error when redefining the same has_an_belongs_to_many association. This commits fix that regression. [Fixes #14983]
* Fix how to compute class name on habtm namespaced.Kassio Borges2014-05-131-0/+12
| | | | | | Thank's for @laurocaetano for the help with tests. :smiley: Fixes #14709
* set a constant for the "anonymous" habtm model fixes #15022Aaron Patterson2014-05-081-0/+6
| | | | | I wanted the middle model to be anonymous, but we have to give it a name for marshal support. :'(
* Fixed HABTM's CollectionAssociation sizeFred Wu2014-05-081-0/+18
| | | | | HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded. This addresses both #14913 and #14914 for master.
* Fix custom join_table name on habtm reflectionsKassio Borges2014-04-251-0/+5
| | | | | | When used a custom join_table name on a habtm, rails was not saving it on Reflections. This causes a problem when rails loads fixtures, because it uses the reflections to set database with fixtures.