Created
May 9, 2012 10:33
-
-
Save shingara/2643623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Issue with default_scope and eager loading" do | |
class Post | |
include Mongoid::Document | |
belongs_to :blog | |
end | |
class Blog | |
include Mongoid::Document | |
has_many :posts | |
default_scope includes(:posts) | |
end | |
let(:blog) { | |
Blog.create | |
} | |
let!(:posts) { | |
2.times { | |
blog.posts.create | |
} | |
} | |
it 'should have one post associate' do | |
Mongoid.identity_map_enabled = true | |
Mongoid.unit_of_work do | |
Blog.find(blog.id).posts.should have(2).entries | |
Blog.where(:_id => blog.id).first.posts.should have(2).entries | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment