aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix problem with loading polymorphic associations which have been defined in ↵Jon Leighton2011-05-221-0/+7
| | | | an abstract superclass. Fixes #552.
* Pass the attribute and option hashes to build_associationAndrew White2011-05-171-0/+13
| | | | | | | The build_association method was added as an API for plugins to hook into in 1398db0. This commit restores this API and the ability to override class.new to return a subclass based on a virtual attribute in the attributes hash.
* CollectionAssociation#merge_target_lists should write to the underlying ↵Jon Leighton2011-05-141-0/+10
| | | | attributes when copying, rather than using the assignment method
* Add test to specify that attributes from an association's conditions should ↵Jon Leighton2011-05-101-4/+23
| | | | be assigned without mass-assignment protection when a record is built on the association.
* Don't use mass-assignment protection when applying the ↵Jon Leighton2011-05-101-0/+9
| | | | scoped.scope_for_create. Fixes #481.
* Add failing tests according to #479.José Valim2011-05-101-0/+15
|
* Add failing tests, according to #480.José Valim2011-05-101-0/+14
|
* Fix for lighthouse #6741Nick Howard2011-05-011-0/+24
| | | | | | | - adds tests for find_or_create_by and find_or_initialize_by on has_many associations - changes the behavior of ActiveRecord::Associations::CollectionProxy#method_missing to differ to ActiveRecord::FinderMethods#find_or_instantiator_by_attributes for arg processing and saving so find_or_create_by's api on associations will be consistent w/ the api for model classes.
* Deprecated support for passing hashes and relations to default_scope, in ↵Jon Leighton2011-04-121-7/+7
| | | | favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
* Added new #update_column method.Sebastian Martinez2011-03-271-3/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-3/+3
| | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-3/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Add interpolation of association conditions back in, in the form of proc { ↵Jon Leighton2011-02-141-1/+0
| | | | ... } rather than instance_eval-ing strings
* Correctly update counter caches on deletion for has_many :through [#2824 ↵Jon Leighton2011-02-071-8/+14
| | | | state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business.
* AssociationCollection#clear can basically just use #delete_all, except it ↵Jon Leighton2011-01-301-3/+6
| | | | should return self.
* AssociationCollection#to_ary should definitely dup the target! Also changed ↵Jon Leighton2011-01-301-0/+7
| | | | #replace which was previously incorrect, but the test passed due to the fact that to_a was not duping.
* DRY up first/last and hence make last benefit from the bugfix in firstJon Leighton2011-01-301-0/+6
|
* We shouldn't be using scoped.scoping { ... } to build associated records, as ↵Jon Leighton2011-01-301-1/+17
| | | | this can affect validations/callbacks/etc inside the record itself [#6252 state:resolved]
* Raise ActiveRecord::RecordNotSaved if an AssociationCollection fails to be ↵Jon Leighton2011-01-111-0/+13
| | | | replaced
* has_many associations with :dependent => :delete_all should update the ↵Jon Leighton2010-12-201-0/+12
| | | | counter cache when deleting records
* removing unused variablesAaron Patterson2010-11-221-2/+1
|
* reloading an association will properly set attributes of instantiated ↵Aaron Patterson2010-11-161-0/+21
| | | | objects. Thanks Brian Palmer [#5802 state:resolved]
* if association is already loaded and if a find operation is performed on the ↵Neeraj Singh2010-11-151-0/+11
| | | | | | already loaded association list with an empty hash then do not perform another sql [#5972 state:resolved]
* fisting a bunch of unused variable warningsAaron Patterson2010-11-151-9/+7
|
* use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-6/+6
| | | | | | | | | | | - persisted? is the API defined in ActiveModel - makes it easier for extension libraries to conform to ActiveModel APIs without concern for whether the extended object is specifically ActiveRecord [#5927 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* AssociationCollection#include? working properly for objects added with build ↵Marcelo Giorgi2010-09-301-0/+6
| | | | method [#3472 state:resolved]
* Set attributes properly for model built from association with conditions ↵Marcelo Giorgi2010-09-281-0/+12
| | | | | | [#5562 state:resolved] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Change relation merging to always append select, group and order valuesPratik Naik2010-08-311-20/+5
|
* While creating a new record using has_many create method default scope of ↵Neeraj Singh2010-08-191-0/+19
| | | | | | | | | | | child should be respected. author.posts.create should take into account default_scope defined on post. [#3939: state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* code gardening: we have assert_(nil|blank|present), more concise, with ↵Xavier Noria2010-08-171-2/+2
| | | | better default failure messages - let's use them
* fixed joining of attributes when using find_or_create_by with multiple ↵Jon Buda2010-07-281-0/+9
| | | | | | attributes through an association Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Remove unintentional API changes. [#1108]Pratik Naik2010-07-141-41/+9
|
* count method should not take options if it is operated on has_many ↵Neeraj Singh2010-07-131-0/+26
| | | | | | | | association which has finder_sql or counter_sql [#2395 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* renaming test name to fix accidently overrideSubba Rao Pasupuleti2010-07-131-1/+1
| | | | | | [#5076 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* fix ActiveRecord `destroy_all` so it returns destroyed recordsMislav Marohnić2010-07-081-2/+5
| | | | Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* AssociationCollection#create_by_*, find_or_create_by_* work properly now. ↵Aaron Patterson2010-06-291-0/+62
| | | | | | [#1108 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* do order by id when finding first fixture to ensure that it is correct oneRaimonds Simanovskis2010-06-041-1/+1
| | | | (as otherwise was failing under JRuby and oracle_enhanced adapter)
* Use better assertion methods for testingNeeraj Singh2010-05-191-10/+3
| | | | | | [#4645 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix for get_ids when including a belongs_to association on a has_many ↵Diego Algorta2010-05-151-0/+4
| | | | | | association [#2896 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Add tests to prevent regression of lazy evaluation of has_many ..., ↵Andrew White2010-04-041-0/+18
| | | | | | | | :dependent => :___ [#2627 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Add :dependent = to has_one and has_many [#3075 state:resolved]Rizwan Reza2010-03-281-0/+8
|
* Fix associations to call :destroy or :delete based on the right :dependent ↵Carlos Antonio da Silva2010-03-091-19/+1
| | | | | | option Signed-off-by: José Valim <jose.valim@gmail.com>
* Forgot to revert tests from that last commitJoshua Peek2009-12-121-8/+0
|
* Revert "Fix instance_eval calls to association proxies"Joshua Peek2009-12-121-1/+0
| | | | | | | | | | I think it may of broke the build. Lets see. This reverts commit 49e943c4f0ac3459bd53023167aaa08fc8e46733. Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
* Fix postgresql AR test failureJohn Pignata2009-12-111-2/+2
| | | | | | | | Due to the ordering of the returning result set, the test fails under the postgresql adapter. Order results by id prior to checking the first item [#3542 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix instance_eval calls to association proxiesMat Brown2009-12-021-0/+8
| | | | | | | | In the current stable, ActiveRecord::Associations::AssociationProxy#method_missing calls yield() if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly. [#3412 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* delete correct records for a has_many with :primary_key and :dependent => ↵Matt Jones2009-11-101-0/+12
| | | | | | :delete_all Signed-off-by: Michael Koziarski <michael@koziarski.com>
* Changed ActiveRecord to use new callbacks and speed up observers by only ↵José Valim2009-09-081-1/+1
| | | | | | notifying events that are actually being consumed. Signed-off-by: Joshua Peek <josh@joshpeek.com>
* Fix test dependency on taggingsJeremy Kemper2009-08-091-1/+2
|
* Fix that counter_cache breaks with has_many :dependent => :nullify.Gabe da Silveira2009-08-091-0/+25
| | | | | | [#1196 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>