aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/nested_attributes_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add test to avoid regression of 58e48d5292242f000dc8a87fdbb1c0ccdcf286d8Gabriel Sobrinho & Ricardo Henrique2012-11-081-0/+11
|
* Ensure nested attributes is restored in case of a test failureCarlos Antonio da Silva2012-11-031-1/+1
|
* Simplify query conditions a bit in nested attributes testCarlos Antonio da Silva2012-11-031-5/+3
| | | | Also refactor the test a bit.
* gradually moving documentation to new hash syntaxAvnerCohen2012-10-101-1/+1
|
* Merge pull request #5248 from ↵Jon Leighton2012-09-211-0/+16
|\ | | | | | | | | jcoleman/should-unset-association-when-an-existing-record-is-destroyed Unset association when existing record is destroyed.
| * Unset association when existing record is destroyed.James Coleman2012-03-021-0/+16
| | | | | | | | To avoid foreign key errors (and invalid data) in the database, when a belongs_to association is destroyed, it should also be nil'd out on the parent object.
* | ensures that the test repairs the validation setupFrancesco Rodriguez2012-08-271-7/+9
| |
* | allow to pass Symbol or Proc into :limit option of ↵Mikhail Dieterle2012-08-261-7/+31
| | | | | | | | #accepts_nested_attributes_for
* | Made ArgumentError messages consistent.Philip Arndt2012-07-061-1/+1
| |
* | Validates_numericality_of is skipped when changing 0 to to non-empty stringAngelo capilleri2012-06-191-0/+10
| | | | | | | | | | | | | | | | | | | | This happens when A has_many many B and A accepts_nested_attributes B that has a numeric colum with initial 0 value. So a.update_attributes({:b_attributes => { :id => b.id, :numeric => 'foo' }}) passes the validation test but, the value of :numeric doesn't change. his commit forces that the update fails with the above conditions. Fixes #6393 Fixes #2331
* | Nested attribute setters can be overridden.Jonathan Mukai & Peter Jaros2012-03-281-0/+13
| | | | | | | | Overriding implementation can call super.
* | remove usages of AS::OrderedHashVishnu Atrai2012-03-031-1/+1
| |
* | Refactored codeRaghunadh2012-02-101-1/+1
|/
* 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>