mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Adds test to check that circular preloading does not modify Model.unscoped (as described in #5667)
This commit is contained in:
parent
68677ffb82
commit
402576b044
3 changed files with 8 additions and 4 deletions
|
@ -1174,6 +1174,12 @@ class EagerAssociationTest < ActiveRecord::TestCase
|
|||
assert_equal Comment.find(1), Comment.preload(:post => :comments).scoping { Comment.find(1) }
|
||||
end
|
||||
|
||||
test "circular preload does not modify unscoped" do
|
||||
expected = FirstPost.unscoped.find(2)
|
||||
FirstPost.preload(:comments => :first_post).find(1)
|
||||
assert_equal expected, FirstPost.unscoped.find(2)
|
||||
end
|
||||
|
||||
test "preload ignores the scoping" do
|
||||
assert_equal(
|
||||
Comment.find(1).post,
|
||||
|
|
|
@ -1099,10 +1099,6 @@ class RelationTest < ActiveRecord::TestCase
|
|||
assert_equal 'honda', FastCar.unscoped { FastCar.order_using_old_style.limit(1).first.name}
|
||||
end
|
||||
|
||||
def test_unscoped_relation_clones
|
||||
assert_not_equal CoolCar.unscoped.object_id, CoolCar.unscoped.object_id
|
||||
end
|
||||
|
||||
def test_intersection_with_array
|
||||
relation = Author.where(:name => "David")
|
||||
rails_author = relation.first
|
||||
|
|
|
@ -9,6 +9,8 @@ class Comment < ActiveRecord::Base
|
|||
belongs_to :post, :counter_cache => true
|
||||
has_many :ratings
|
||||
|
||||
belongs_to :first_post, :foreign_key => :post_id
|
||||
|
||||
has_many :children, :class_name => 'Comment', :foreign_key => :parent_id
|
||||
belongs_to :parent, :class_name => 'Comment', :counter_cache => :children_count
|
||||
|
||||
|
|
Loading…
Reference in a new issue