mongoid 7.3.3 → 7.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mongoid/association/embedded/batchable.rb +2 -0
- data/lib/mongoid/version.rb +1 -1
- data/spec/integration/associations/embeds_many_spec.rb +139 -0
- data/spec/mongoid/copyable_spec.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +650 -643
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bbeda0aba58b991964f1d6c687a8120cdeac497c9fbeef7b376386470519b6d
|
4
|
+
data.tar.gz: 4d3d62eef06a3d4502e5b846a6d38905f8bdca608598a1fb3e04945d364589d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8e5502f46048cd2f726aad05b44de638e6c3af5d3de59c33625fa0c5de6b4f8099155e643273afe17f2678239c52f2ffd3412587a6c23067ce1804eb2849c89
|
7
|
+
data.tar.gz: c84fd0380200bcb1c13fb49e3baa6c095670657fdcf6cfbd60f422448327faf37bdc43f9ac5334fcf96a883ed70bb9be9c42430b06f357a98e393ef2cec77efc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -82,6 +82,7 @@ module Mongoid
|
|
82
82
|
def batch_replace(docs)
|
83
83
|
if docs.blank?
|
84
84
|
if _assigning? && !empty?
|
85
|
+
_base.delayed_atomic_sets.clear
|
85
86
|
_base.add_atomic_unset(first)
|
86
87
|
target_duplicate = _target.dup
|
87
88
|
pre_process_batch_remove(target_duplicate, :delete)
|
@@ -93,6 +94,7 @@ module Mongoid
|
|
93
94
|
_base.delayed_atomic_sets.clear unless _assigning?
|
94
95
|
docs = normalize_docs(docs).compact
|
95
96
|
_target.clear and _unscoped.clear
|
97
|
+
_base.delayed_atomic_unsets.clear
|
96
98
|
inserts = execute_batch_set(docs)
|
97
99
|
add_atomic_sets(inserts)
|
98
100
|
end
|
data/lib/mongoid/version.rb
CHANGED
@@ -65,4 +65,143 @@ describe 'embeds_many associations' do
|
|
65
65
|
include_examples 'does not delete the target from the database'
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
context 'assigning attributes to the same association' do
|
70
|
+
context 'setting then clearing' do
|
71
|
+
let(:canvas) do
|
72
|
+
Canvas.create!(shapes: [Shape.new])
|
73
|
+
end
|
74
|
+
|
75
|
+
shared_examples 'persists correctly' do
|
76
|
+
it 'persists correctly' do
|
77
|
+
canvas.shapes.should be_empty
|
78
|
+
_canvas = Canvas.find(canvas.id)
|
79
|
+
_canvas.shapes.should be_empty
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'via assignment operator' do
|
84
|
+
before do
|
85
|
+
canvas.shapes = [Shape.new, Shape.new]
|
86
|
+
canvas.shapes = []
|
87
|
+
canvas.save!
|
88
|
+
end
|
89
|
+
|
90
|
+
include_examples 'persists correctly'
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'via attributes=' do
|
94
|
+
before do
|
95
|
+
canvas.attributes = {shapes: [Shape.new, Shape.new]}
|
96
|
+
canvas.attributes = {shapes: []}
|
97
|
+
canvas.save!
|
98
|
+
end
|
99
|
+
|
100
|
+
include_examples 'persists correctly'
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'via assign_attributes' do
|
104
|
+
before do
|
105
|
+
canvas.assign_attributes(shapes: [Shape.new, Shape.new])
|
106
|
+
canvas.assign_attributes(shapes: [])
|
107
|
+
canvas.save!
|
108
|
+
end
|
109
|
+
|
110
|
+
include_examples 'persists correctly'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'clearing then setting' do
|
115
|
+
let(:canvas) do
|
116
|
+
Canvas.create!(shapes: [Shape.new])
|
117
|
+
end
|
118
|
+
|
119
|
+
shared_examples 'persists correctly' do
|
120
|
+
it 'persists correctly' do
|
121
|
+
canvas.shapes.length.should eq 2
|
122
|
+
_canvas = Canvas.find(canvas.id)
|
123
|
+
_canvas.shapes.length.should eq 2
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'via assignment operator' do
|
128
|
+
before do
|
129
|
+
canvas.shapes = []
|
130
|
+
canvas.shapes = [Shape.new, Shape.new]
|
131
|
+
canvas.save!
|
132
|
+
end
|
133
|
+
|
134
|
+
include_examples 'persists correctly'
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'via attributes=' do
|
138
|
+
before do
|
139
|
+
canvas.attributes = {shapes: []}
|
140
|
+
canvas.attributes = {shapes: [Shape.new, Shape.new]}
|
141
|
+
canvas.save!
|
142
|
+
end
|
143
|
+
|
144
|
+
include_examples 'persists correctly'
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'via assign_attributes' do
|
148
|
+
before do
|
149
|
+
canvas.assign_attributes(shapes: [])
|
150
|
+
canvas.assign_attributes(shapes: [Shape.new, Shape.new])
|
151
|
+
canvas.save!
|
152
|
+
end
|
153
|
+
|
154
|
+
include_examples 'persists correctly'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'updating a child then clearing' do
|
159
|
+
let(:canvas) do
|
160
|
+
Canvas.create!(shapes: [Shape.new])
|
161
|
+
end
|
162
|
+
|
163
|
+
shared_examples 'persists correctly' do
|
164
|
+
it 'persists correctly' do
|
165
|
+
canvas.shapes.should be_empty
|
166
|
+
_canvas = Canvas.find(canvas.id)
|
167
|
+
_canvas.shapes.should be_empty
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'via assignment operator' do
|
172
|
+
before do
|
173
|
+
# Mongoid uses the new value of `x` in the $pullAll query,
|
174
|
+
# which doesn't match the document that is in the database,
|
175
|
+
# resulting in the empty array assignment not taking effect.
|
176
|
+
pending 'MONGOID-5037'
|
177
|
+
|
178
|
+
canvas.shapes.first.x = 1
|
179
|
+
canvas.shapes = []
|
180
|
+
canvas.save!
|
181
|
+
end
|
182
|
+
|
183
|
+
include_examples 'persists correctly'
|
184
|
+
end
|
185
|
+
|
186
|
+
context 'via attributes=' do
|
187
|
+
before do
|
188
|
+
canvas.shapes.first.x = 1
|
189
|
+
canvas.attributes = {shapes: []}
|
190
|
+
canvas.save!
|
191
|
+
end
|
192
|
+
|
193
|
+
include_examples 'persists correctly'
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'via assign_attributes' do
|
197
|
+
before do
|
198
|
+
canvas.shapes.first.x = 1
|
199
|
+
canvas.assign_attributes(shapes: [])
|
200
|
+
canvas.save!
|
201
|
+
end
|
202
|
+
|
203
|
+
include_examples 'persists correctly'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
68
207
|
end
|
@@ -91,7 +91,7 @@ describe Mongoid::Copyable do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'calls constructor with explicitly declared attributes only' do
|
94
|
-
expect(cls).to receive(:new).with('name' => 'test').and_call_original
|
94
|
+
expect(cls).to receive(:new).with({'name' => 'test'}).and_call_original
|
95
95
|
cloned
|
96
96
|
end
|
97
97
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|