mongoid 4.0.0.alpha1 → 4.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +1 -1
- data/lib/config/locales/en.yml +4 -6
- data/lib/mongoid/attributes/processing.rb +1 -1
- data/lib/mongoid/contextual.rb +2 -0
- data/lib/mongoid/contextual/map_reduce.rb +3 -1
- data/lib/mongoid/contextual/none.rb +90 -0
- data/lib/mongoid/criteria.rb +25 -0
- data/lib/mongoid/extensions/array.rb +1 -1
- data/lib/mongoid/extensions/big_decimal.rb +1 -1
- data/lib/mongoid/extensions/date.rb +1 -1
- data/lib/mongoid/extensions/date_time.rb +3 -3
- data/lib/mongoid/extensions/float.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +1 -1
- data/lib/mongoid/extensions/integer.rb +1 -1
- data/lib/mongoid/extensions/object.rb +3 -3
- data/lib/mongoid/extensions/object_id.rb +1 -1
- data/lib/mongoid/extensions/range.rb +1 -1
- data/lib/mongoid/extensions/regexp.rb +1 -1
- data/lib/mongoid/extensions/set.rb +1 -1
- data/lib/mongoid/extensions/string.rb +1 -1
- data/lib/mongoid/extensions/symbol.rb +1 -1
- data/lib/mongoid/extensions/time.rb +1 -1
- data/lib/mongoid/extensions/time_with_zone.rb +1 -1
- data/lib/mongoid/findable.rb +1 -0
- data/lib/mongoid/interceptable.rb +4 -2
- data/lib/mongoid/persistable.rb +4 -3
- data/lib/mongoid/relations/embedded/many.rb +1 -1
- data/lib/mongoid/relations/metadata.rb +8 -4
- data/lib/mongoid/relations/referenced/many.rb +1 -1
- data/lib/mongoid/relations/touchable.rb +1 -1
- data/lib/mongoid/scopable.rb +2 -26
- data/lib/mongoid/validatable/uniqueness.rb +13 -0
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +0 -4
- data/spec/app/models/acolyte.rb +1 -1
- data/spec/app/models/address.rb +2 -2
- data/spec/app/models/appointment.rb +1 -1
- data/spec/app/models/audio.rb +1 -1
- data/spec/app/models/dog.rb +1 -1
- data/spec/app/models/event.rb +1 -1
- data/spec/app/models/house.rb +1 -1
- data/spec/app/models/message.rb +8 -0
- data/spec/app/models/person.rb +3 -2
- data/spec/app/models/player.rb +2 -2
- data/spec/app/models/post.rb +3 -2
- data/spec/app/models/preference.rb +1 -1
- data/spec/app/models/sound.rb +1 -1
- data/spec/app/models/symptom.rb +1 -1
- data/spec/app/models/tree.rb +2 -2
- data/spec/app/models/video.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +3 -3
- data/spec/mongoid/changeable_spec.rb +3 -3
- data/spec/mongoid/contextual/mongo_spec.rb +14 -14
- data/spec/mongoid/contextual/none_spec.rb +127 -0
- data/spec/mongoid/criteria/scopable_spec.rb +6 -6
- data/spec/mongoid/criteria_spec.rb +52 -96
- data/spec/mongoid/errors/invalid_scope_spec.rb +2 -2
- data/spec/mongoid/errors/mongoid_error_spec.rb +1 -1
- data/spec/mongoid/extensions/date_time_spec.rb +1 -1
- data/spec/mongoid/fields_spec.rb +6 -7
- data/spec/mongoid/findable_spec.rb +65 -0
- data/spec/mongoid/interceptable_spec.rb +11 -11
- data/spec/mongoid/persistable_spec.rb +4 -4
- data/spec/mongoid/relations/auto_save_spec.rb +1 -1
- data/spec/mongoid/relations/bindings/embedded/in_spec.rb +5 -5
- data/spec/mongoid/relations/bindings/embedded/many_spec.rb +1 -1
- data/spec/mongoid/relations/bindings/embedded/one_spec.rb +2 -2
- data/spec/mongoid/relations/bindings/referenced/in_spec.rb +14 -14
- data/spec/mongoid/relations/bindings/referenced/many_spec.rb +4 -4
- data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +10 -10
- data/spec/mongoid/relations/bindings/referenced/one_spec.rb +6 -6
- data/spec/mongoid/relations/builders/referenced/in_spec.rb +2 -2
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +1 -1
- data/spec/mongoid/relations/cascading/delete_spec.rb +2 -2
- data/spec/mongoid/relations/cascading/destroy_spec.rb +4 -4
- data/spec/mongoid/relations/cascading/nullify_spec.rb +2 -2
- data/spec/mongoid/relations/cascading/restrict_spec.rb +4 -4
- data/spec/mongoid/relations/eager_spec.rb +6 -6
- data/spec/mongoid/relations/embedded/many_spec.rb +36 -5
- data/spec/mongoid/relations/metadata_spec.rb +34 -15
- data/spec/mongoid/relations/referenced/many_spec.rb +19 -4
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +7 -7
- data/spec/mongoid/relations/referenced/one_spec.rb +1 -1
- data/spec/mongoid/relations/targets/enumerable_spec.rb +2 -2
- data/spec/mongoid/relations/touchable_spec.rb +17 -0
- data/spec/mongoid/scopable_spec.rb +17 -40
- data/spec/mongoid/sessions/options_spec.rb +1 -1
- data/spec/mongoid/timestamps/timeless_spec.rb +6 -6
- data/spec/mongoid/timestamps/updated/short_spec.rb +1 -1
- data/spec/mongoid/timestamps/updated_spec.rb +1 -1
- data/spec/mongoid/timestamps_spec.rb +2 -2
- data/spec/mongoid/validatable/associated_spec.rb +4 -4
- data/spec/mongoid/validatable/length_spec.rb +7 -7
- data/spec/mongoid/validatable/presence_spec.rb +6 -6
- data/spec/mongoid/validatable/uniqueness_spec.rb +44 -3
- data/spec/rails/mongoid_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -0
- metadata +55 -50
@@ -8,7 +8,7 @@ describe Mongoid::Errors::MongoidError do
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
["message", "summary", "resolution"].each do |name|
|
11
|
-
::I18n.
|
11
|
+
expect(::I18n).to receive(:translate).
|
12
12
|
with("mongoid.errors.messages.#{key}.#{name}", {}).
|
13
13
|
and_return(name)
|
14
14
|
end
|
data/spec/mongoid/fields_spec.rb
CHANGED
@@ -61,7 +61,7 @@ describe Mongoid::Fields do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should have alias method #\{field}_t" do
|
64
|
-
product.method(:name_t).
|
64
|
+
expect(product.method(:name_t)).to eq product.method(:name_translations)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -72,7 +72,7 @@ describe Mongoid::Fields do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "does not respond to the alias method" do
|
75
|
-
product.
|
75
|
+
expect(product).to_not respond_to(:price_t)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -174,7 +174,7 @@ describe Mongoid::Fields do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should have alias method #\{field}_t=" do
|
177
|
-
product.method(:name_t=).
|
177
|
+
expect(product.method(:name_t=)).to eq product.method(:name_translations=)
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -185,7 +185,7 @@ describe Mongoid::Fields do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
it "does not respond to the alias method" do
|
188
|
-
product.
|
188
|
+
expect(product).to_not respond_to(:price_t=)
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
@@ -956,7 +956,7 @@ describe Mongoid::Fields do
|
|
956
956
|
context "when option is nil" do
|
957
957
|
|
958
958
|
it "calls the handler" do
|
959
|
-
handler.
|
959
|
+
expect(handler).to receive(:call)
|
960
960
|
User.field :custom, option: nil, overwrite: true
|
961
961
|
end
|
962
962
|
end
|
@@ -964,8 +964,7 @@ describe Mongoid::Fields do
|
|
964
964
|
context "when option is not provided" do
|
965
965
|
|
966
966
|
it "does not call the handler" do
|
967
|
-
handler.
|
968
|
-
|
967
|
+
expect(handler).to receive(:call).never
|
969
968
|
User.field :custom, overwrite: true
|
970
969
|
end
|
971
970
|
end
|
@@ -286,6 +286,71 @@ describe Mongoid::Findable do
|
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
|
+
describe ".none" do
|
290
|
+
|
291
|
+
let!(:depeche) do
|
292
|
+
Band.create(name: "Depeche Mode", likes: 3)
|
293
|
+
end
|
294
|
+
|
295
|
+
context "when not chaining any criteria" do
|
296
|
+
|
297
|
+
it "returns no records" do
|
298
|
+
expect(Band.none).to be_empty
|
299
|
+
end
|
300
|
+
|
301
|
+
it "has an empty count" do
|
302
|
+
expect(Band.none.count).to eq(0)
|
303
|
+
end
|
304
|
+
|
305
|
+
it "returns nil for first" do
|
306
|
+
expect(Band.none.first).to be_nil
|
307
|
+
end
|
308
|
+
|
309
|
+
it "returns nil for last" do
|
310
|
+
expect(Band.none.last).to be_nil
|
311
|
+
end
|
312
|
+
|
313
|
+
it "returns zero for length" do
|
314
|
+
expect(Band.none.length).to eq(0)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "returns zero for size" do
|
318
|
+
expect(Band.none.size).to eq(0)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
context "when chaining criteria after the none" do
|
323
|
+
|
324
|
+
let(:criteria) do
|
325
|
+
Band.none.where(name: "Depeche Mode")
|
326
|
+
end
|
327
|
+
|
328
|
+
it "returns no records" do
|
329
|
+
expect(criteria).to be_empty
|
330
|
+
end
|
331
|
+
|
332
|
+
it "has an empty count" do
|
333
|
+
expect(criteria.count).to eq(0)
|
334
|
+
end
|
335
|
+
|
336
|
+
it "returns nil for first" do
|
337
|
+
expect(criteria.first).to be_nil
|
338
|
+
end
|
339
|
+
|
340
|
+
it "returns nil for last" do
|
341
|
+
expect(criteria.last).to be_nil
|
342
|
+
end
|
343
|
+
|
344
|
+
it "returns zero for length" do
|
345
|
+
expect(criteria.length).to eq(0)
|
346
|
+
end
|
347
|
+
|
348
|
+
it "returns zero for size" do
|
349
|
+
expect(criteria.size).to eq(0)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
289
354
|
describe ".pluck" do
|
290
355
|
|
291
356
|
let!(:depeche) do
|
@@ -216,7 +216,7 @@ describe Mongoid::Interceptable do
|
|
216
216
|
context "callback returns true" do
|
217
217
|
|
218
218
|
before do
|
219
|
-
artist.
|
219
|
+
expect(artist).to receive(:before_create_stub).once.and_return(true)
|
220
220
|
artist.save
|
221
221
|
end
|
222
222
|
|
@@ -228,7 +228,7 @@ describe Mongoid::Interceptable do
|
|
228
228
|
context "callback returns false" do
|
229
229
|
|
230
230
|
before do
|
231
|
-
artist.
|
231
|
+
expect(artist).to receive(:before_create_stub).once.and_return(false)
|
232
232
|
artist.save
|
233
233
|
end
|
234
234
|
|
@@ -253,7 +253,7 @@ describe Mongoid::Interceptable do
|
|
253
253
|
context "when the callback returns true" do
|
254
254
|
|
255
255
|
before do
|
256
|
-
artist.
|
256
|
+
expect(artist).to receive(:before_save_stub).once.and_return(true)
|
257
257
|
end
|
258
258
|
|
259
259
|
it "the save returns true" do
|
@@ -264,7 +264,7 @@ describe Mongoid::Interceptable do
|
|
264
264
|
context "when callback returns false" do
|
265
265
|
|
266
266
|
before do
|
267
|
-
artist.
|
267
|
+
expect(artist).to receive(:before_save_stub).once.and_return(false)
|
268
268
|
end
|
269
269
|
|
270
270
|
it "the save returns false" do
|
@@ -288,7 +288,7 @@ describe Mongoid::Interceptable do
|
|
288
288
|
context "when the callback returns true" do
|
289
289
|
|
290
290
|
before do
|
291
|
-
artist.
|
291
|
+
expect(artist).to receive(:before_save_stub).once.and_return(true)
|
292
292
|
end
|
293
293
|
|
294
294
|
it "the save returns true" do
|
@@ -299,7 +299,7 @@ describe Mongoid::Interceptable do
|
|
299
299
|
context "when the callback returns false" do
|
300
300
|
|
301
301
|
before do
|
302
|
-
artist.
|
302
|
+
expect(artist).to receive(:before_save_stub).once.and_return(false)
|
303
303
|
end
|
304
304
|
|
305
305
|
it "the save returns false" do
|
@@ -326,7 +326,7 @@ describe Mongoid::Interceptable do
|
|
326
326
|
context "when the callback returns true" do
|
327
327
|
|
328
328
|
before do
|
329
|
-
artist.
|
329
|
+
expect(artist).to receive(:before_destroy_stub).once.and_return(true)
|
330
330
|
end
|
331
331
|
|
332
332
|
it "the destroy returns true" do
|
@@ -337,7 +337,7 @@ describe Mongoid::Interceptable do
|
|
337
337
|
context "when the callback returns false" do
|
338
338
|
|
339
339
|
before do
|
340
|
-
artist.
|
340
|
+
expect(artist).to receive(:before_destroy_stub).once.and_return(false)
|
341
341
|
end
|
342
342
|
|
343
343
|
it "the destroy returns false" do
|
@@ -485,7 +485,7 @@ describe Mongoid::Interceptable do
|
|
485
485
|
context "when saving the root" do
|
486
486
|
|
487
487
|
it "only executes the callbacks once for each embed" do
|
488
|
-
note.
|
488
|
+
expect(note).to receive(:update_saved).twice
|
489
489
|
band.save
|
490
490
|
end
|
491
491
|
end
|
@@ -503,7 +503,7 @@ describe Mongoid::Interceptable do
|
|
503
503
|
end
|
504
504
|
|
505
505
|
it "doesn't cascade the initialize" do
|
506
|
-
Service.
|
506
|
+
expect_any_instance_of(Service).to receive(:after_initialize_called=).never
|
507
507
|
expect(Person.find(person.id)).to eq(person)
|
508
508
|
end
|
509
509
|
end
|
@@ -1556,7 +1556,7 @@ describe Mongoid::Interceptable do
|
|
1556
1556
|
context "when saving the document" do
|
1557
1557
|
|
1558
1558
|
it "only executes the callbacks once" do
|
1559
|
-
callback.
|
1559
|
+
expect(callback).to receive(:execute).once
|
1560
1560
|
callback.save
|
1561
1561
|
end
|
1562
1562
|
end
|
@@ -61,7 +61,7 @@ describe Mongoid::Persistable do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
before do
|
64
|
-
Moped::Query.
|
64
|
+
expect_any_instance_of(Moped::Query).to receive(:update).with(operations).and_call_original
|
65
65
|
end
|
66
66
|
|
67
67
|
let!(:update) do
|
@@ -88,7 +88,7 @@ describe Mongoid::Persistable do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
before do
|
91
|
-
Moped::Query.
|
91
|
+
expect_any_instance_of(Moped::Query).to receive(:update).with(operations).and_call_original
|
92
92
|
end
|
93
93
|
|
94
94
|
let!(:update) do
|
@@ -116,7 +116,7 @@ describe Mongoid::Persistable do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
before do
|
119
|
-
Moped::Query.
|
119
|
+
expect_any_instance_of(Moped::Query).to receive(:update).with(operations).and_call_original
|
120
120
|
end
|
121
121
|
|
122
122
|
let!(:update) do
|
@@ -153,7 +153,7 @@ describe Mongoid::Persistable do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
before do
|
156
|
-
Moped::Query.
|
156
|
+
expect_any_instance_of(Moped::Query).to receive(:update).with(operations).and_call_original
|
157
157
|
end
|
158
158
|
|
159
159
|
let!(:update) do
|
@@ -56,7 +56,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "does nothing" do
|
59
|
-
name.
|
59
|
+
expect(name).to receive(:namable=).never
|
60
60
|
binding.bind_one
|
61
61
|
end
|
62
62
|
end
|
@@ -92,7 +92,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "does not overwrite the existing metadata" do
|
95
|
-
address.
|
95
|
+
expect(address).to receive(:metadata=).never
|
96
96
|
binding.bind_one
|
97
97
|
end
|
98
98
|
end
|
@@ -105,7 +105,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "does nothing" do
|
108
|
-
address.
|
108
|
+
expect(address).to receive(:addressable=).never
|
109
109
|
binding.bind_one
|
110
110
|
end
|
111
111
|
end
|
@@ -135,7 +135,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
135
135
|
context "when the document is not unbindable" do
|
136
136
|
|
137
137
|
it "does nothing" do
|
138
|
-
name.
|
138
|
+
expect(name).to receive(:namable=).never
|
139
139
|
binding.unbind_one
|
140
140
|
end
|
141
141
|
end
|
@@ -162,7 +162,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
162
162
|
context "when the document is not unbindable" do
|
163
163
|
|
164
164
|
it "does nothing" do
|
165
|
-
address.
|
165
|
+
expect(address).to receive(:addressable=).never
|
166
166
|
binding.unbind_one
|
167
167
|
end
|
168
168
|
end
|
@@ -46,7 +46,7 @@ describe Mongoid::Relations::Bindings::Embedded::Many do
|
|
46
46
|
context "when the document is not bindable" do
|
47
47
|
|
48
48
|
it "does nothing" do
|
49
|
-
person.addresses.
|
49
|
+
expect(person.addresses).to receive(:<<).never
|
50
50
|
binding.bind_one(address)
|
51
51
|
end
|
52
52
|
end
|
@@ -42,7 +42,7 @@ describe Mongoid::Relations::Bindings::Embedded::One do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "does nothing" do
|
45
|
-
person.
|
45
|
+
expect(person).to receive(:name=).never
|
46
46
|
binding.bind_one
|
47
47
|
end
|
48
48
|
end
|
@@ -69,7 +69,7 @@ describe Mongoid::Relations::Bindings::Embedded::One do
|
|
69
69
|
context "when the document is not unbindable" do
|
70
70
|
|
71
71
|
it "does nothing" do
|
72
|
-
person.
|
72
|
+
expect(person).to receive(:name=).never
|
73
73
|
binding.unbind_one
|
74
74
|
end
|
75
75
|
end
|
@@ -33,8 +33,8 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
33
33
|
context "when the document is bindable with default pk" do
|
34
34
|
|
35
35
|
before do
|
36
|
-
person.
|
37
|
-
game.
|
36
|
+
expect(person).to receive(:save).never
|
37
|
+
expect(game).to receive(:save).never
|
38
38
|
binding.bind_one
|
39
39
|
end
|
40
40
|
|
@@ -52,8 +52,8 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
52
52
|
before do
|
53
53
|
Game.belongs_to :person, index: true, validate: true, primary_key: :username
|
54
54
|
|
55
|
-
person.
|
56
|
-
game.
|
55
|
+
expect(person).to receive(:save).never
|
56
|
+
expect(game).to receive(:save).never
|
57
57
|
binding.bind_one
|
58
58
|
end
|
59
59
|
|
@@ -81,7 +81,7 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "does nothing" do
|
84
|
-
game.
|
84
|
+
expect(game).to receive(:person=).never
|
85
85
|
binding.bind_one
|
86
86
|
end
|
87
87
|
end
|
@@ -96,8 +96,8 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
96
96
|
context "when the document is bindable" do
|
97
97
|
|
98
98
|
before do
|
99
|
-
person.
|
100
|
-
post.
|
99
|
+
expect(person).to receive(:save).never
|
100
|
+
expect(post).to receive(:save).never
|
101
101
|
binding.bind_one
|
102
102
|
end
|
103
103
|
|
@@ -117,7 +117,7 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
it "does nothing" do
|
120
|
-
post.
|
120
|
+
expect(post).to receive(:person=).never
|
121
121
|
binding.bind_one
|
122
122
|
end
|
123
123
|
end
|
@@ -136,8 +136,8 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
136
136
|
|
137
137
|
before do
|
138
138
|
binding.bind_one
|
139
|
-
person.
|
140
|
-
game.
|
139
|
+
expect(person).to receive(:delete).never
|
140
|
+
expect(game).to receive(:delete).never
|
141
141
|
binding.unbind_one
|
142
142
|
end
|
143
143
|
|
@@ -153,7 +153,7 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
153
153
|
context "when the document is not unbindable" do
|
154
154
|
|
155
155
|
it "does nothing" do
|
156
|
-
game.
|
156
|
+
expect(game).to receive(:person=).never
|
157
157
|
binding.unbind_one
|
158
158
|
end
|
159
159
|
end
|
@@ -169,8 +169,8 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
169
169
|
|
170
170
|
before do
|
171
171
|
binding.bind_one
|
172
|
-
person.
|
173
|
-
post.
|
172
|
+
expect(person).to receive(:delete).never
|
173
|
+
expect(post).to receive(:delete).never
|
174
174
|
binding.unbind_one
|
175
175
|
end
|
176
176
|
|
@@ -186,7 +186,7 @@ describe Mongoid::Relations::Bindings::Referenced::In do
|
|
186
186
|
context "when the document is not unbindable" do
|
187
187
|
|
188
188
|
it "does nothing" do
|
189
|
-
post.
|
189
|
+
expect(post).to receive(:person=).never
|
190
190
|
binding.unbind_one
|
191
191
|
end
|
192
192
|
end
|
@@ -46,7 +46,7 @@ describe Mongoid::Relations::Bindings::Referenced::Many do
|
|
46
46
|
context "when the document is not bindable" do
|
47
47
|
|
48
48
|
it "does nothing" do
|
49
|
-
person.posts.
|
49
|
+
expect(person.posts).to receive(:<<).never
|
50
50
|
binding.bind_one(post)
|
51
51
|
end
|
52
52
|
end
|
@@ -62,8 +62,8 @@ describe Mongoid::Relations::Bindings::Referenced::Many do
|
|
62
62
|
|
63
63
|
before do
|
64
64
|
binding.bind_one(target.first)
|
65
|
-
person.
|
66
|
-
post.
|
65
|
+
expect(person).to receive(:delete).never
|
66
|
+
expect(post).to receive(:delete).never
|
67
67
|
binding.unbind_one(target.first)
|
68
68
|
end
|
69
69
|
|
@@ -79,7 +79,7 @@ describe Mongoid::Relations::Bindings::Referenced::Many do
|
|
79
79
|
context "when the documents are not unbindable" do
|
80
80
|
|
81
81
|
it "does nothing" do
|
82
|
-
person.
|
82
|
+
expect(person).to receive(:posts=).never
|
83
83
|
binding.unbind_one(target.first)
|
84
84
|
end
|
85
85
|
end
|