Skip to content

Commit

Permalink
Merge 26da3f2 into f4f489e
Browse files Browse the repository at this point in the history
  • Loading branch information
cheredon committed Oct 31, 2014
2 parents f4f489e + 26da3f2 commit b1d0226
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mongoid/query_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def with_cache(context = :cursor, more = false, &block)
key = cache_key.push(context)

if more
QueryCache.cache_table[key].push(*yield)
docs = yield
QueryCache.cache_table[key].push(*docs)
docs
elsif QueryCache.cache_table.has_key?(key)
instrument(key) { QueryCache.cache_table[key] }
else
Expand Down
4 changes: 4 additions & 0 deletions spec/mongoid/query_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
expect(Band.all.to_a.length).to eq(123)
end

it "#pluck returns the same count of objects" do
expect(Band.pluck(:name).length).to eq(123)
end

end

context "when inserting an index" do
Expand Down

0 comments on commit b1d0226

Please sign in to comment.