spec/mongoid/atomic/modifiers_spec.rb in mongoid-7.1.11 vs spec/mongoid/atomic/modifiers_spec.rb in mongoid-7.2.0.rc1
- old
+ new
@@ -7,10 +7,30 @@
let(:modifiers) do
described_class.new
end
+ describe "#push_conflict?" do
+ let(:result) { modifiers.send(:push_conflict?, field) }
+
+ context 'for embeds many subdocument' do
+ context 'when another field on subdocument is being set' do
+ before do
+ modifiers.set('foo.0.a' => 1)
+ end
+
+ let(:field) { 'foo' }
+
+ it 'does not conflict' do
+ pending 'https://jira.mongodb.org/browse/MONGOID-4982'
+
+ result.should be false
+ end
+ end
+ end
+ end
+
describe "#add_to_set" do
context "when the unique adds are empty" do
before do
@@ -340,9 +360,36 @@
}
}
}
)
end
+ end
+ end
+
+ context 'when there is another operation on a sibling of a key which is nested' do
+
+ let(:first_op) do
+ { "addresses.0.name" => 'test' }
+ end
+
+ let(:push_op) do
+ { "addresses.0.locations" => { "street" => "Oxford St" } }
+ end
+
+ before do
+ modifiers.set(first_op)
+ modifiers.push(push_op)
+ end
+
+ it "does not conflict and adds push to top level" do
+ pending 'https://jira.mongodb.org/browse/MONGOID-4982'
+
+ modifiers.should == {
+ '$set' => { "addresses.0.name" => 'test' },
+ '$push' => {"addresses.0.locations" => {'$each' => [
+ { "street" => "Oxford St" },
+ ]}},
+ }
end
end
end
describe "#set" do