mongoid-history 0.8.3 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -1
  3. data/.document +5 -5
  4. data/.github/workflows/test.yml +72 -0
  5. data/.gitignore +46 -46
  6. data/.rspec +2 -2
  7. data/.rubocop.yml +6 -6
  8. data/.rubocop_todo.yml +99 -99
  9. data/CHANGELOG.md +173 -163
  10. data/CONTRIBUTING.md +117 -118
  11. data/Dangerfile +1 -1
  12. data/Gemfile +49 -40
  13. data/LICENSE.txt +20 -20
  14. data/README.md +609 -608
  15. data/RELEASING.md +66 -67
  16. data/Rakefile +24 -24
  17. data/UPGRADING.md +53 -53
  18. data/lib/mongoid/history/attributes/base.rb +72 -72
  19. data/lib/mongoid/history/attributes/create.rb +45 -45
  20. data/lib/mongoid/history/attributes/destroy.rb +34 -34
  21. data/lib/mongoid/history/attributes/update.rb +104 -104
  22. data/lib/mongoid/history/options.rb +177 -177
  23. data/lib/mongoid/history/trackable.rb +588 -583
  24. data/lib/mongoid/history/tracker.rb +247 -247
  25. data/lib/mongoid/history/version.rb +5 -5
  26. data/lib/mongoid/history.rb +77 -77
  27. data/lib/mongoid-history.rb +1 -1
  28. data/mongoid-history.gemspec +25 -25
  29. data/perf/benchmark_modified_attributes_for_create.rb +65 -65
  30. data/perf/gc_suite.rb +21 -21
  31. data/spec/integration/embedded_in_polymorphic_spec.rb +112 -112
  32. data/spec/integration/integration_spec.rb +976 -976
  33. data/spec/integration/multi_relation_spec.rb +47 -47
  34. data/spec/integration/multiple_trackers_spec.rb +68 -68
  35. data/spec/integration/nested_embedded_documents_spec.rb +64 -64
  36. data/spec/integration/nested_embedded_documents_tracked_in_parent_spec.rb +124 -124
  37. data/spec/integration/nested_embedded_polymorphic_documents_spec.rb +115 -115
  38. data/spec/integration/subclasses_spec.rb +47 -47
  39. data/spec/integration/track_history_order_spec.rb +84 -84
  40. data/spec/integration/validation_failure_spec.rb +76 -76
  41. data/spec/spec_helper.rb +32 -30
  42. data/spec/support/error_helpers.rb +7 -0
  43. data/spec/support/mongoid.rb +11 -11
  44. data/spec/support/mongoid_history.rb +12 -12
  45. data/spec/unit/attributes/base_spec.rb +141 -141
  46. data/spec/unit/attributes/create_spec.rb +342 -342
  47. data/spec/unit/attributes/destroy_spec.rb +228 -228
  48. data/spec/unit/attributes/update_spec.rb +342 -342
  49. data/spec/unit/callback_options_spec.rb +165 -165
  50. data/spec/unit/embedded_methods_spec.rb +87 -87
  51. data/spec/unit/history_spec.rb +58 -58
  52. data/spec/unit/my_instance_methods_spec.rb +555 -555
  53. data/spec/unit/options_spec.rb +365 -365
  54. data/spec/unit/singleton_methods_spec.rb +406 -406
  55. data/spec/unit/store/default_store_spec.rb +11 -11
  56. data/spec/unit/store/request_store_spec.rb +13 -13
  57. data/spec/unit/trackable_spec.rb +1057 -987
  58. data/spec/unit/tracker_spec.rb +190 -190
  59. metadata +9 -7
  60. data/.travis.yml +0 -36
@@ -1,342 +1,342 @@
1
- require 'spec_helper'
2
-
3
- describe Mongoid::History::Attributes::Create do
4
- before :each do
5
- class ModelOne
6
- include Mongoid::Document
7
- include Mongoid::History::Trackable
8
-
9
- store_in collection: :model_ones
10
- field :foo
11
- field :b, as: :bar
12
-
13
- track_history on: :foo
14
- end
15
- end
16
-
17
- after :each do
18
- Object.send(:remove_const, :ModelOne)
19
- end
20
-
21
- let(:base) { described_class.new(obj_one) }
22
- subject { base }
23
-
24
- describe '#attributes' do
25
- subject { base.attributes }
26
-
27
- describe 'fields' do
28
- let(:obj_one) { ModelOne.new }
29
- let(:obj_one) { ModelOne.new(foo: 'Foo', bar: 'Bar') }
30
- it { is_expected.to eq('foo' => [nil, 'Foo']) }
31
- end
32
-
33
- describe '#insert_embeds_one_changes' do
34
- context 'when untracked relation' do
35
- before :each do
36
- class ModelTwo
37
- include Mongoid::Document
38
- include Mongoid::History::Trackable
39
-
40
- store_in collection: :model_twos
41
-
42
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
43
- embeds_one :emb_one_one
44
- else
45
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
46
- end
47
-
48
- track_history on: :fields
49
- end
50
-
51
- class EmbOneOne
52
- include Mongoid::Document
53
-
54
- field :em_bar
55
- embedded_in :model_one
56
- end
57
- end
58
-
59
- after :each do
60
- Object.send(:remove_const, :ModelTwo)
61
- Object.send(:remove_const, :EmbOneOne)
62
- end
63
-
64
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
65
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
66
-
67
- it { is_expected.to eq({}) }
68
- end
69
-
70
- context 'when tracked relation' do
71
- before :each do
72
- class ModelTwo
73
- include Mongoid::Document
74
- include Mongoid::History::Trackable
75
-
76
- store_in collection: :model_twos
77
-
78
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
79
- embeds_one :emb_one_one
80
- else
81
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
82
- end
83
-
84
- track_history on: :emb_one_one
85
- end
86
-
87
- class EmbOneOne
88
- include Mongoid::Document
89
-
90
- field :em_bar
91
- embedded_in :model_one
92
- end
93
- end
94
-
95
- after :each do
96
- Object.send(:remove_const, :ModelTwo)
97
- Object.send(:remove_const, :EmbOneOne)
98
- end
99
-
100
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
101
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
102
-
103
- it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
104
- end
105
-
106
- context 'when paranoia_field without alias' do
107
- before :each do
108
- class ModelTwo
109
- include Mongoid::Document
110
- include Mongoid::History::Trackable
111
-
112
- store_in collection: :model_twos
113
-
114
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
115
- embeds_one :emb_one_one
116
- else
117
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
118
- end
119
-
120
- track_history on: :emb_one_one
121
- end
122
-
123
- class EmbOneOne
124
- include Mongoid::Document
125
- include Mongoid::History::Trackable
126
-
127
- field :em_bar
128
- field :removed_at
129
-
130
- embedded_in :model_one
131
-
132
- history_settings paranoia_field: :removed_at
133
- end
134
- end
135
-
136
- after :each do
137
- Object.send(:remove_const, :ModelTwo)
138
- Object.send(:remove_const, :EmbOneOne)
139
- end
140
-
141
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
142
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar', removed_at: Time.now) }
143
-
144
- it { is_expected.to eq({}) }
145
- end
146
-
147
- context 'when paranoia_field with alias' do
148
- before :each do
149
- class ModelTwo
150
- include Mongoid::Document
151
- include Mongoid::History::Trackable
152
-
153
- store_in collection: :model_twos
154
-
155
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
156
- embeds_one :emb_one_one
157
- else
158
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
159
- end
160
-
161
- track_history on: :emb_one_one
162
- end
163
-
164
- class EmbOneOne
165
- include Mongoid::Document
166
- include Mongoid::History::Trackable
167
-
168
- field :em_bar
169
- field :rmvt, as: :removed_at
170
-
171
- embedded_in :model_one
172
-
173
- history_settings paranoia_field: :removed_at
174
- end
175
- end
176
-
177
- after :each do
178
- Object.send(:remove_const, :ModelTwo)
179
- Object.send(:remove_const, :EmbOneOne)
180
- end
181
-
182
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
183
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar', removed_at: Time.now) }
184
-
185
- it { is_expected.to eq({}) }
186
- end
187
-
188
- context 'with permitted attributes' do
189
- before :each do
190
- class ModelTwo
191
- include Mongoid::Document
192
- include Mongoid::History::Trackable
193
-
194
- store_in collection: :model_twos
195
-
196
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
197
- embeds_one :emb_one_one
198
- else
199
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
200
- end
201
-
202
- track_history on: [{ emb_one_one: :em_bar }]
203
- end
204
-
205
- class EmbOneOne
206
- include Mongoid::Document
207
- include Mongoid::History::Trackable
208
-
209
- field :em_foo
210
- field :em_bar
211
-
212
- embedded_in :model_one
213
- end
214
- end
215
-
216
- after :each do
217
- Object.send(:remove_const, :ModelTwo)
218
- Object.send(:remove_const, :EmbOneOne)
219
- end
220
-
221
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
222
- let(:emb_obj) { EmbOneOne.new(em_foo: 'Em-Foo', em_bar: 'Em-Bar') }
223
-
224
- it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
225
- end
226
-
227
- context 'when relation with alias' do
228
- before :each do
229
- class ModelTwo
230
- include Mongoid::Document
231
- include Mongoid::History::Trackable
232
-
233
- store_in collection: :model_twos
234
-
235
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
236
- embeds_one :emb_one_one, store_as: :eoo
237
- else
238
- embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne', store_as: :eoo
239
- end
240
-
241
- track_history on: :emb_one_one
242
- end
243
-
244
- class EmbOneOne
245
- include Mongoid::Document
246
-
247
- field :em_bar
248
- embedded_in :model_one
249
- end
250
- end
251
-
252
- after :each do
253
- Object.send(:remove_const, :ModelTwo)
254
- Object.send(:remove_const, :EmbOneOne)
255
- end
256
-
257
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
258
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
259
-
260
- it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
261
- end
262
-
263
- context 'when no object' do
264
- before :each do
265
- class ModelTwo
266
- include Mongoid::Document
267
- include Mongoid::History::Trackable
268
-
269
- store_in collection: :model_twos
270
-
271
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
272
- embeds_one :emb_one_one, store_as: :eoo
273
- else
274
- embeds_one :emb_one_one, store_as: :eoo, inverse_class_name: 'EmbOneOne'
275
- end
276
-
277
- track_history on: :emb_one_one
278
- end
279
-
280
- class EmbOneOne
281
- include Mongoid::Document
282
-
283
- field :em_bar
284
- embedded_in :model_one
285
- end
286
- end
287
-
288
- after :each do
289
- Object.send(:remove_const, :ModelTwo)
290
- Object.send(:remove_const, :EmbOneOne)
291
- end
292
-
293
- let(:obj_one) { ModelTwo.new }
294
-
295
- it { is_expected.to eq({}) }
296
- end
297
-
298
- context 'when object not paranoid' do
299
- before :each do
300
- class ModelTwo
301
- include Mongoid::Document
302
- include Mongoid::History::Trackable
303
-
304
- store_in collection: :model_twos
305
-
306
- if Mongoid::Compatibility::Version.mongoid7_or_newer?
307
- embeds_one :emb_one_one, store_as: :eoo
308
- else
309
- embeds_one :emb_one_one, store_as: :eoo, inverse_class_name: 'EmbOneOne'
310
- end
311
-
312
- track_history on: :emb_one_one
313
- end
314
-
315
- class EmbOneOne
316
- include Mongoid::Document
317
- include Mongoid::History::Trackable
318
-
319
- field :em_bar
320
- field :cancelled_at
321
-
322
- embedded_in :model_one
323
-
324
- history_settings paranoia_field: :cancelled_at
325
- end
326
- end
327
-
328
- after :each do
329
- Object.send(:remove_const, :ModelTwo)
330
- Object.send(:remove_const, :EmbOneOne)
331
- end
332
-
333
- let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
334
- let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
335
-
336
- it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
337
- end
338
- end
339
-
340
- pending '#insert_embeds_many_changes'
341
- end
342
- end
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::History::Attributes::Create do
4
+ before :each do
5
+ class ModelOne
6
+ include Mongoid::Document
7
+ include Mongoid::History::Trackable
8
+
9
+ store_in collection: :model_ones
10
+ field :foo
11
+ field :b, as: :bar
12
+
13
+ track_history on: :foo
14
+ end
15
+ end
16
+
17
+ after :each do
18
+ Object.send(:remove_const, :ModelOne)
19
+ end
20
+
21
+ let(:base) { described_class.new(obj_one) }
22
+ subject { base }
23
+
24
+ describe '#attributes' do
25
+ subject { base.attributes }
26
+
27
+ describe 'fields' do
28
+ let(:obj_one) { ModelOne.new }
29
+ let(:obj_one) { ModelOne.new(foo: 'Foo', bar: 'Bar') }
30
+ it { is_expected.to eq('foo' => [nil, 'Foo']) }
31
+ end
32
+
33
+ describe '#insert_embeds_one_changes' do
34
+ context 'when untracked relation' do
35
+ before :each do
36
+ class ModelTwo
37
+ include Mongoid::Document
38
+ include Mongoid::History::Trackable
39
+
40
+ store_in collection: :model_twos
41
+
42
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
43
+ embeds_one :emb_one_one
44
+ else
45
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
46
+ end
47
+
48
+ track_history on: :fields
49
+ end
50
+
51
+ class EmbOneOne
52
+ include Mongoid::Document
53
+
54
+ field :em_bar
55
+ embedded_in :model_one
56
+ end
57
+ end
58
+
59
+ after :each do
60
+ Object.send(:remove_const, :ModelTwo)
61
+ Object.send(:remove_const, :EmbOneOne)
62
+ end
63
+
64
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
65
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
66
+
67
+ it { is_expected.to eq({}) }
68
+ end
69
+
70
+ context 'when tracked relation' do
71
+ before :each do
72
+ class ModelTwo
73
+ include Mongoid::Document
74
+ include Mongoid::History::Trackable
75
+
76
+ store_in collection: :model_twos
77
+
78
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
79
+ embeds_one :emb_one_one
80
+ else
81
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
82
+ end
83
+
84
+ track_history on: :emb_one_one
85
+ end
86
+
87
+ class EmbOneOne
88
+ include Mongoid::Document
89
+
90
+ field :em_bar
91
+ embedded_in :model_one
92
+ end
93
+ end
94
+
95
+ after :each do
96
+ Object.send(:remove_const, :ModelTwo)
97
+ Object.send(:remove_const, :EmbOneOne)
98
+ end
99
+
100
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
101
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
102
+
103
+ it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
104
+ end
105
+
106
+ context 'when paranoia_field without alias' do
107
+ before :each do
108
+ class ModelTwo
109
+ include Mongoid::Document
110
+ include Mongoid::History::Trackable
111
+
112
+ store_in collection: :model_twos
113
+
114
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
115
+ embeds_one :emb_one_one
116
+ else
117
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
118
+ end
119
+
120
+ track_history on: :emb_one_one
121
+ end
122
+
123
+ class EmbOneOne
124
+ include Mongoid::Document
125
+ include Mongoid::History::Trackable
126
+
127
+ field :em_bar
128
+ field :removed_at
129
+
130
+ embedded_in :model_one
131
+
132
+ history_settings paranoia_field: :removed_at
133
+ end
134
+ end
135
+
136
+ after :each do
137
+ Object.send(:remove_const, :ModelTwo)
138
+ Object.send(:remove_const, :EmbOneOne)
139
+ end
140
+
141
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
142
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar', removed_at: Time.now) }
143
+
144
+ it { is_expected.to eq({}) }
145
+ end
146
+
147
+ context 'when paranoia_field with alias' do
148
+ before :each do
149
+ class ModelTwo
150
+ include Mongoid::Document
151
+ include Mongoid::History::Trackable
152
+
153
+ store_in collection: :model_twos
154
+
155
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
156
+ embeds_one :emb_one_one
157
+ else
158
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
159
+ end
160
+
161
+ track_history on: :emb_one_one
162
+ end
163
+
164
+ class EmbOneOne
165
+ include Mongoid::Document
166
+ include Mongoid::History::Trackable
167
+
168
+ field :em_bar
169
+ field :rmvt, as: :removed_at
170
+
171
+ embedded_in :model_one
172
+
173
+ history_settings paranoia_field: :removed_at
174
+ end
175
+ end
176
+
177
+ after :each do
178
+ Object.send(:remove_const, :ModelTwo)
179
+ Object.send(:remove_const, :EmbOneOne)
180
+ end
181
+
182
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
183
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar', removed_at: Time.now) }
184
+
185
+ it { is_expected.to eq({}) }
186
+ end
187
+
188
+ context 'with permitted attributes' do
189
+ before :each do
190
+ class ModelTwo
191
+ include Mongoid::Document
192
+ include Mongoid::History::Trackable
193
+
194
+ store_in collection: :model_twos
195
+
196
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
197
+ embeds_one :emb_one_one
198
+ else
199
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne'
200
+ end
201
+
202
+ track_history on: [{ emb_one_one: :em_bar }]
203
+ end
204
+
205
+ class EmbOneOne
206
+ include Mongoid::Document
207
+ include Mongoid::History::Trackable
208
+
209
+ field :em_foo
210
+ field :em_bar
211
+
212
+ embedded_in :model_one
213
+ end
214
+ end
215
+
216
+ after :each do
217
+ Object.send(:remove_const, :ModelTwo)
218
+ Object.send(:remove_const, :EmbOneOne)
219
+ end
220
+
221
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
222
+ let(:emb_obj) { EmbOneOne.new(em_foo: 'Em-Foo', em_bar: 'Em-Bar') }
223
+
224
+ it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
225
+ end
226
+
227
+ context 'when relation with alias' do
228
+ before :each do
229
+ class ModelTwo
230
+ include Mongoid::Document
231
+ include Mongoid::History::Trackable
232
+
233
+ store_in collection: :model_twos
234
+
235
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
236
+ embeds_one :emb_one_one, store_as: :eoo
237
+ else
238
+ embeds_one :emb_one_one, inverse_class_name: 'EmbOneOne', store_as: :eoo
239
+ end
240
+
241
+ track_history on: :emb_one_one
242
+ end
243
+
244
+ class EmbOneOne
245
+ include Mongoid::Document
246
+
247
+ field :em_bar
248
+ embedded_in :model_one
249
+ end
250
+ end
251
+
252
+ after :each do
253
+ Object.send(:remove_const, :ModelTwo)
254
+ Object.send(:remove_const, :EmbOneOne)
255
+ end
256
+
257
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
258
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
259
+
260
+ it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
261
+ end
262
+
263
+ context 'when no object' do
264
+ before :each do
265
+ class ModelTwo
266
+ include Mongoid::Document
267
+ include Mongoid::History::Trackable
268
+
269
+ store_in collection: :model_twos
270
+
271
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
272
+ embeds_one :emb_one_one, store_as: :eoo
273
+ else
274
+ embeds_one :emb_one_one, store_as: :eoo, inverse_class_name: 'EmbOneOne'
275
+ end
276
+
277
+ track_history on: :emb_one_one
278
+ end
279
+
280
+ class EmbOneOne
281
+ include Mongoid::Document
282
+
283
+ field :em_bar
284
+ embedded_in :model_one
285
+ end
286
+ end
287
+
288
+ after :each do
289
+ Object.send(:remove_const, :ModelTwo)
290
+ Object.send(:remove_const, :EmbOneOne)
291
+ end
292
+
293
+ let(:obj_one) { ModelTwo.new }
294
+
295
+ it { is_expected.to eq({}) }
296
+ end
297
+
298
+ context 'when object not paranoid' do
299
+ before :each do
300
+ class ModelTwo
301
+ include Mongoid::Document
302
+ include Mongoid::History::Trackable
303
+
304
+ store_in collection: :model_twos
305
+
306
+ if Mongoid::Compatibility::Version.mongoid7_or_newer?
307
+ embeds_one :emb_one_one, store_as: :eoo
308
+ else
309
+ embeds_one :emb_one_one, store_as: :eoo, inverse_class_name: 'EmbOneOne'
310
+ end
311
+
312
+ track_history on: :emb_one_one
313
+ end
314
+
315
+ class EmbOneOne
316
+ include Mongoid::Document
317
+ include Mongoid::History::Trackable
318
+
319
+ field :em_bar
320
+ field :cancelled_at
321
+
322
+ embedded_in :model_one
323
+
324
+ history_settings paranoia_field: :cancelled_at
325
+ end
326
+ end
327
+
328
+ after :each do
329
+ Object.send(:remove_const, :ModelTwo)
330
+ Object.send(:remove_const, :EmbOneOne)
331
+ end
332
+
333
+ let(:obj_one) { ModelTwo.new(emb_one_one: emb_obj) }
334
+ let(:emb_obj) { EmbOneOne.new(em_bar: 'Em-Bar') }
335
+
336
+ it { is_expected.to eq('emb_one_one' => [nil, { '_id' => emb_obj._id, 'em_bar' => 'Em-Bar' }]) }
337
+ end
338
+ end
339
+
340
+ pending '#insert_embeds_many_changes'
341
+ end
342
+ end