Skip to content

Commit

Permalink
Providing fix for failing specs in mongodb#1869. Fixes #1868, Closes m…
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Mar 29, 2012
1 parent 878126a commit 73a744d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
For instructions on upgrading to newer versions, visit
[mongoid.org](http://mongoid.org/docs/upgrading.html).

## 2.4.8 (branch: 2.4.0-stable)

* \#1869/\#1868 Delayed atomic sets now uses the atomic path instead of
the metadata name to fix multiple level embedding issues.
(Chris Micacchi provided specs)

## 2.4.7

### Resolved Issues
Expand Down
7 changes: 4 additions & 3 deletions lib/mongoid/relations/embedded/many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,15 @@ def substitute(replacement)
docs = replacement.compact
proxy.target = docs
self._unscoped = docs.dup
if _assigning?
base.delayed_atomic_sets[metadata.name.to_s] = proxy.as_document
end
proxy.target.each_with_index do |doc, index|
integrate(doc)
doc._index = index
doc.save if base.persisted? && !_assigning?
end
if _assigning?
name = proxy.first.atomic_path
base.delayed_atomic_sets[name] = proxy.as_document
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def pushable?
new? &&
embedded_many? &&
_parent.persisted? &&
!_parent.delayed_atomic_sets[metadata.name.to_s]
!_parent.delayed_atomic_sets[atomic_path]
end

# Determine if the document can be set.
Expand Down
6 changes: 2 additions & 4 deletions spec/functional/mongoid/relations/embedded/many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,10 @@
end

context "when the attributes have changed" do
before do
Mongoid.logger = Logger.new('/tmp/log.txt', :debug)

before do
attributes["city"] = "Berlin"
attributes["locations"][0]["name"] = "Home"

person.addresses.first.update_attributes(attributes)
end

Expand All @@ -539,7 +537,7 @@
end

it "does not persist the locations collection to the person document" do
person.reload['locations'].should be_nil
person.reload[:locations].should be_nil
end
end
end
Expand Down

0 comments on commit 73a744d

Please sign in to comment.