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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf7cd241503d485cd393a4d0885629b2916aa5542083a281ff8883111938044e
4
- data.tar.gz: f10cbf0946bd1b4a6f93deebe42fc2f9a728704d0565e1ea392df3007e5d6cc7
3
+ metadata.gz: 8bbeda0aba58b991964f1d6c687a8120cdeac497c9fbeef7b376386470519b6d
4
+ data.tar.gz: 4d3d62eef06a3d4502e5b846a6d38905f8bdca608598a1fb3e04945d364589d8
5
5
  SHA512:
6
- metadata.gz: 7e2a3edf8051a2ad27202288f73dc7d284effe7c766ab5d7a7274c0901e793eb124fd178d5b366ffb3b3c196e9e69cded899b66dab8f15044a9981e4b12f5c55
7
- data.tar.gz: 3c990c42772c0b2f61eccf88bdb8ad5f26779fe62c8ad119f5717d9da48c558a85deaf56aa8ff088f97c2aee2e41c2a29cfec67018142a59c79e3ea13f8e415c
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
@@ -2,5 +2,5 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  module Mongoid
5
- VERSION = "7.3.3"
5
+ VERSION = "7.3.4"
6
6
  end
@@ -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