Permalink
Browse files

Adds test to check that circular preloading does not modify Model.uns…

…coped (as described in #5667)
  • Loading branch information...
1 parent 68677ff commit 402576b044ce1cb06c3e48061f62542d0908fa17 @benedikt benedikt committed Apr 3, 2012
@@ -1174,6 +1174,12 @@ def test_deep_including_through_habtm
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 @@ def test_unscoped_block_style
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

0 comments on commit 402576b

Please sign in to comment.