Permalink
Browse files

Ensure source is cleared as well.

In case keys have been removed database side.
  • Loading branch information...
1 parent baa538c commit 00c1b36a1425c240424361d7cc8688a7d28b3985 @jnunemaker committed Aug 3, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −1 lib/flipper/adapters/mongo/document.rb
  2. +2 −1 spec/flipper/adapters/mongo/document_spec.rb
@@ -68,9 +68,9 @@ def source
def load
@loaded = true
+ @source.clear
@source.update @collection.find_one(@criteria) || {}
end
-
end
end
end
@@ -48,6 +48,7 @@ def document
describe "#read" do
context "existing key" do
before do
+ source['baz'] = 'wick'
collection.update(criteria, {'$set' => {'foo' => 'bar'}}, options)
@result = subject.read('foo')
end
@@ -56,7 +57,7 @@ def document
@result.should eq('bar')
end
- it "loads source hash" do
+ it "clears and loads source hash" do
source.should eq({
'_id' => id,
'foo' => 'bar',

0 comments on commit 00c1b36

Please sign in to comment.