aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/nested_attributes_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* added failing tests for has_many, has_one and belongs_to associations with ↵Jakub Kuźma2011-12-211-5/+0
| | | | strict mass assignment sanitizer, fixed build_record to not merge creation_attributes, removed failing nested attributes tests (that feature was broken anyway) #4051
* Allow nested attributes in associations to update values in it's owner ↵Andrew Kaspick2011-12-141-0/+5
| | | | object. Fixes a regression from 3.0.x
* Exclude _destroy parameter in :all_blank check (issue #2937)Aaron Christy2011-10-171-0/+8
|
* assign_nested_attributes_for_collection_association should work with Ruby ↵Franck Verrot2011-07-201-0/+5
| | | | | | 1.9 [Closes #2106] Children attributes can be either String's or Symbol's, so let's check if the object responds to to_i.
* 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.
* Destroying records via nested attributes works independent of reject_if:Durran Jordan2011-04-051-0/+8
| | | | | | | | | | - When a :_destroy truthiness is provided in the attributes hash, the record should get destroyed regardless of the result of the proc or method supplied to :reject_if. (If :allow_destroy is true) [#6006 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-181-5/+5
| | | | manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
* Fixing incorrectly writtent testcaseAlexey Nayden2011-01-281-2/+2
|
* test_first_and_array_index_zero_methods_return_the_same_value_when_nested_at ↵Alexey Nayden2011-01-281-0/+9
| | | | tributes_are_set_to_update_existing_record added
* In a number of places in the tests, we only need to turn off transactional ↵Jon Leighton2011-01-111-2/+2
| | | | fixtures when the DB does not support savepoints. This speeds the test run up by about 8-9% on my computer, when running rake test_sqlite3_mem :)
* Allow assignment on has_one :through where the owner is a new record [#5137 ↵Jon Leighton2011-01-031-1/+0
| | | | | | | | | | state:resolved] This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct. Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things. Phew, long commit message!
* Improved strategy for updating a belongs_to association when the foreign key ↵Jon Leighton2010-12-231-2/+3
| | | | changes. Rather than resetting each affected association when the foreign key changes, we should lazily check for 'staleness' (where fk does not match target id) when the association is accessed.
* fix warnings, stop using global variablesAaron Patterson2010-11-301-2/+1
|
* If a nested_attribute is being marked for destruction and at the same time ↵Neeraj Singh2010-11-241-1/+14
| | | | | | | | an attr_accessor value is being assigned then the value being assigned is being ignored. This patch is a fix for that issue. [#5939 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Fixed bug in active_record/nested_attributes where an empty string id caused ↵Santiago Pastorino2010-11-111-0/+8
| | | | | | | | an ActiveRecord::RecordNotFound error. Found by [Ben Tillman] [#5638 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-8/+8
| | | | | | | | | | | - 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>
* Revert 0c0b0aa0f223523331afdc157fb3992a121bf497 which introduced a security ↵Michael Koziarski2010-10-151-14/+12
| | | | | | | | | | vulnerability. This addresses CVE-2010-3933 Conflicts: activerecord/lib/active_record/nested_attributes.rb
* fixing indentation warningAaron Patterson2010-09-281-1/+1
|
* Fix for #5579 involved the code change for both has_one and has_many ↵Neeraj Singh2010-09-271-1/+9
| | | | | | | | relationships. The path included test only for has_one. This patch adds test for has_many relationship. [#5706 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix for nested_attributes with has_many association fails when a single ↵Neeraj Singh2010-09-271-0/+8
| | | | | | | | record is being updated. [#5705 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* reject_id option should be respected while using nested_attributesNeeraj Singh2010-09-241-0/+9
| | | | | | [#5579 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* nested attributes tests should rely on associated objects to verify results ↵Subba Rao Pasupuleti2010-09-011-57/+64
| | | | | | not on assert_difference [#5206 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-10/+10
| | | | 's/[ \t]*$//' -i {} \;)
* fixed indentation in test casesMark Turner2010-08-111-1/+1
| | | | Signed-off-by: wycats <wycats@gmail.com>
* association load target shouldn't replace recordsSzetobo2010-07-211-1/+13
| | | | | | | | from db if it is already loaded by nested attributes assignment [#5053 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* In nested_attributes when association is not loaded and associationSubba Rao Pasupuleti2010-07-211-0/+6
| | | | | | | | record is saved and then in memory record attributes should be saved [#5053 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* - without the id test is passing even if I change :allow_destroy from ↵Neeraj Singh2010-07-211-2/+47
| | | | | | 'false' - adding more tests to strengthen the test suite Signed-off-by: José Valim <jose.valim@gmail.com>
* This patch changes update_attribute implementatino so:Neeraj Singh2010-07-081-9/+9
| | | | | | | | | | - it will only save the attribute it has been asked to save and not all dirty attributes - it does not invoke callbacks - it does change updated_at/on Signed-off-by: José Valim <jose.valim@gmail.com>
* Don't remove scheduled destroys when loading an association. [#4642 ↵James Le Cuirot2010-07-011-0/+6
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Fixes #2415 by creating a new instance of the Model when saving attributes ↵George Montana Harkin2010-06-271-13/+15
| | | | | | to that model and the associated attributes already exist. Tests included. [#2415 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Don't overwrite unsaved updates when loading an association but preserve the ↵James Le Cuirot2010-06-201-0/+21
| | | | | | | | order of the loaded records. Reapplied from before but now allows already-saved records to be refreshed. [#4830 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Revert "Don't overwrite unsaved updates when loading an association but ↵José Valim2010-06-111-14/+0
| | | | | | | | preserve the order of the loaded records. [#4642 state:open]" This commit introduced a regression described in ticket [#4830]. This reverts commit 0265c708b9696c3943518ad5f3dabdc22c5eba11.
* Don't overwrite unsaved updates when loading an association but preserve the ↵James Le Cuirot2010-06-091-0/+14
| | | | | | order of the loaded records. [#4642 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fixing test class names and refactor line in autosave associationCarlos Antonio da Silva2010-06-071-2/+2
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Nested records (re: autosave) are now updated even when the intermediate ↵Ian White2010-05-181-0/+80
| | | | | | parent record is unchanged [#4242 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Use primary key in conditions, not 'id' [#4395 state:resolved]Mathieu Arnold2010-05-041-0/+25
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure not to load the entire association when bulk updating existing ↵Pratik Naik2010-04-141-1/+11
| | | | records using nested attributes
* Raise a RecordNotFound if an ID in nested attributes is given but doesn't ↵Eloy Duran2010-01-071-4/+20
| | | | return a record. [#2415 state:resolved]
* Moved the validation logic to the association reflection and refactored ↵Eloy Duran2010-01-071-2/+2
| | | | autosave_association.rb a bit.
* Remove deprecated '_delete' option from NestedAttributes.Eloy Duran2010-01-071-6/+0
|
* Refactored nested attributes a bit around :reject_if => :all_blank.Eloy Duran2010-01-071-1/+4
|
* Make nested attributes behave like in 2.3.5 and add a sanity test for it ↵José Valim2010-01-021-1/+1
| | | | with I18n.
* Refactored previous changes to nested attributes.Eloy Duran2009-12-281-15/+26
|
* Add an :update_only option to accepts_nested_attributes_for for to-one ↵Michael Siebert2009-12-281-0/+31
| | | | | | associations. [#2563 state:resolved] Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
* Make sure to not add autosave callbacks multiple times. [#3575 state:resolved]Eloy Duran2009-12-281-0/+9
| | | | This makes sure that, in a HABTM association, only one join record is craeted.
* Add a :limit option to specify the maximum number of records that can be ↵Pratik Naik2009-10-091-0/+30
| | | | processed by accepts_nested_attributes_for
* Store entire options hash in the class var rather than just the reject_if ↵Pratik Naik2009-10-091-4/+4
| | | | proc for the nested attributes
* Use indifferent access attributes instead of stringifying themPratik Naik2009-10-081-0/+8
|
* Allow accepts_nested_attributes_for :reject_if option accept symbols for ↵Pratik Naik2009-10-071-0/+20
| | | | | | | | using a method Conflicts: activerecord/lib/active_record/nested_attributes.rb