diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-07-26 15:12:36 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-02 17:12:59 +0200 |
commit | 009aa8825b6932b006f005ac351b82ad8100d7f1 (patch) | |
tree | 5e5a86d710a45399347adbc38a22db1b4a2a3fad /activerecord/test/cases | |
parent | 59693c4c49cce5e4cf53eb54e42e3da07a98467e (diff) | |
download | rails-009aa8825b6932b006f005ac351b82ad8100d7f1.tar.gz rails-009aa8825b6932b006f005ac351b82ad8100d7f1.tar.bz2 rails-009aa8825b6932b006f005ac351b82ad8100d7f1.zip |
Eager loading an association should not change the count of children
[#4971 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index a1c794c084..d328ca630b 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -14,11 +14,24 @@ require 'models/reader' require 'models/parrot' require 'models/ship_part' require 'models/ship' +require 'models/liquid' +require 'models/molecule' +require 'models/electron' class AssociationsTest < ActiveRecord::TestCase fixtures :accounts, :companies, :developers, :projects, :developers_projects, :computers, :people, :readers + def test_eager_loading_should_not_change_count_of_children + liquid = Liquid.create(:name => 'salty') + molecule = liquid.molecules.create(:name => 'molecule_1') + molecule.electrons.create(:name => 'electron_1') + molecule.electrons.create(:name => 'electron_2') + + liquids = Liquid.includes(:molecules => :electrons).where('molecules.id is not null') + assert_equal 1, liquids[0].molecules.length + end + 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") |