aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorByron Bischoff <byronb@gmail.com>2014-10-22 11:39:47 -0700
committerByron Bischoff <byronb@gmail.com>2014-10-22 11:39:47 -0700
commit0f3cefa445c6b43711b29f38257adcedede74baa (patch)
tree55fd8cdd4380f478f4697f3e2ef82c088e3d0850 /activerecord/test/cases/associations
parent19d698d2b45ca33d8709c1993e39d7d9df284e3d (diff)
downloadrails-0f3cefa445c6b43711b29f38257adcedede74baa.tar.gz
rails-0f3cefa445c6b43711b29f38257adcedede74baa.tar.bz2
rails-0f3cefa445c6b43711b29f38257adcedede74baa.zip
copy reflection_scopes’s unscoped value when building scope for preloading, fixes #11036
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb8
1 files changed, 8 insertions, 0 deletions
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)