From 0f3cefa445c6b43711b29f38257adcedede74baa Mon Sep 17 00:00:00 2001 From: Byron Bischoff Date: Wed, 22 Oct 2014 11:39:47 -0700 Subject: =?UTF-8?q?copy=20reflection=5Fscopes=E2=80=99s=20unscoped=20value?= =?UTF-8?q?=20when=20building=20scope=20for=20preloading,=20fixes=20#11036?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/cases/associations/has_many_associations_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index e34b993029..fdbe411f86 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1895,6 +1895,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal [bulb1, bulb2], car.all_bulbs.sort_by(&:id) end + test 'unscopes the default scope of associated model when used with include' do + car = Car.create! + bulb = Bulb.create! name: "other", car: car + + assert_equal bulb, Car.find(car.id).all_bulbs.first + assert_equal bulb, Car.includes(:all_bulbs).find(car.id).all_bulbs.first + end + test "raises RecordNotDestroyed when replaced child can't be destroyed" do car = Car.create! original_child = FailedBulb.create!(car: car) -- cgit v1.2.3