diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-11-05 15:03:35 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-11-05 15:13:23 +0100 |
commit | 8e9cb9787bab976fa3a9a7722c5a024dc8384de4 (patch) | |
tree | ca02ecb6123675b73c62993ea80acfc540199fda /activerecord/test/cases | |
parent | 8d902a949b2ca6695766263756bdd274cf4988d8 (diff) | |
parent | 0f3cefa445c6b43711b29f38257adcedede74baa (diff) | |
download | rails-8e9cb9787bab976fa3a9a7722c5a024dc8384de4.tar.gz rails-8e9cb9787bab976fa3a9a7722c5a024dc8384de4.tar.bz2 rails-8e9cb9787bab976fa3a9a7722c5a024dc8384de4.zip |
Merge pull request #17360 from bronzle/includes_and_unscoped
copy reflection_scopes’s unscoped value when building scope for preloading
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 8 |
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) |