diff options
author | Subba Rao Pasupuleti <subbarao.pasupuleti@gmail.com> | 2010-07-14 23:13:56 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-21 14:25:34 +0200 |
commit | 96b2516c3cbcf900f2e84163baba3db7cb0e37d9 (patch) | |
tree | 3764c55cc2136fb9df862ba8f565848e4f0c2d45 /activerecord/test/cases | |
parent | 0057d2df71ec7c2a788acd3b4bade263fc0fe361 (diff) | |
download | rails-96b2516c3cbcf900f2e84163baba3db7cb0e37d9.tar.gz rails-96b2516c3cbcf900f2e84163baba3db7cb0e37d9.tar.bz2 rails-96b2516c3cbcf900f2e84163baba3db7cb0e37d9.zip |
Strengthening the test for nested_attribute
Loading the associate target in nested_attributes
should load most recent attributes for child
records marked for destruction
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations_test.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 4ae776c35a..ff9e9a472a 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -17,7 +17,8 @@ require 'models/tagging' require 'models/person' require 'models/reader' require 'models/parrot' -require 'models/pirate' +require 'models/ship_part' +require 'models/ship' require 'models/treasure' require 'models/price_estimate' require 'models/club' @@ -29,6 +30,24 @@ class AssociationsTest < ActiveRecord::TestCase fixtures :accounts, :companies, :developers, :projects, :developers_projects, :computers, :people, :readers + def test_loading_the_association_target_should_keep_child_records_marked_for_destruction + ship = Ship.create!(:name => "The good ship Dollypop") + part = ship.parts.create!(:name => "Mast") + part.mark_for_destruction + ship.parts.send(:load_target) + assert ship.parts[0].marked_for_destruction? + end + + def test_loading_the_association_target_should_load_most_recent_attributes_for_child_records_marked_for_destruction + ship = Ship.create!(:name => "The good ship Dollypop") + part = ship.parts.create!(:name => "Mast") + part.mark_for_destruction + ShipPart.find(part.id).update_attribute(:name, 'Deck') + ship.parts.send(:load_target) + assert_equal 'Deck', ship.parts[0].name + end + + def test_include_with_order_works assert_nothing_raised {Account.find(:first, :order => 'id', :include => :firm)} assert_nothing_raised {Account.find(:first, :order => :id, :include => :firm)} |