couchrest_model 2.1.0.rc1 → 2.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +15 -4
- data/Gemfile.activesupport-4.x +4 -0
- data/Gemfile.activesupport-5.x +4 -0
- data/README.md +2 -0
- data/VERSION +1 -1
- data/couchrest_model.gemspec +3 -2
- data/history.md +14 -1
- data/lib/couchrest/model/associations.rb +3 -8
- data/lib/couchrest/model/base.rb +15 -7
- data/lib/couchrest/model/casted_array.rb +22 -34
- data/lib/couchrest/model/configuration.rb +2 -0
- data/lib/couchrest/model/design.rb +4 -3
- data/lib/couchrest/model/designs/view.rb +37 -32
- data/lib/couchrest/model/dirty.rb +93 -19
- data/lib/couchrest/model/embeddable.rb +2 -14
- data/lib/couchrest/model/extended_attachments.rb +2 -4
- data/lib/couchrest/model/persistence.rb +14 -17
- data/lib/couchrest/model/properties.rb +46 -54
- data/lib/couchrest/model/property.rb +0 -3
- data/lib/couchrest/model/proxyable.rb +20 -4
- data/lib/couchrest/model/validations/uniqueness.rb +4 -1
- data/lib/couchrest_model.rb +2 -2
- data/spec/fixtures/models/article.rb +1 -1
- data/spec/fixtures/models/card.rb +2 -1
- data/spec/fixtures/models/person.rb +1 -0
- data/spec/fixtures/models/project.rb +3 -0
- data/spec/unit/assocations_spec.rb +73 -73
- data/spec/unit/attachment_spec.rb +34 -34
- data/spec/unit/base_spec.rb +102 -102
- data/spec/unit/casted_array_spec.rb +7 -7
- data/spec/unit/casted_spec.rb +7 -7
- data/spec/unit/configuration_spec.rb +11 -11
- data/spec/unit/connection_spec.rb +30 -30
- data/spec/unit/core_extensions/{time_parsing.rb → time_parsing_spec.rb} +21 -21
- data/spec/unit/design_spec.rb +38 -38
- data/spec/unit/designs/design_mapper_spec.rb +26 -26
- data/spec/unit/designs/migrations_spec.rb +13 -13
- data/spec/unit/designs/view_spec.rb +319 -274
- data/spec/unit/designs_spec.rb +39 -39
- data/spec/unit/dirty_spec.rb +188 -103
- data/spec/unit/embeddable_spec.rb +119 -117
- data/spec/unit/inherited_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +122 -122
- data/spec/unit/properties_spec.rb +466 -16
- data/spec/unit/property_protection_spec.rb +32 -32
- data/spec/unit/property_spec.rb +45 -436
- data/spec/unit/proxyable_spec.rb +140 -82
- data/spec/unit/subclass_spec.rb +14 -14
- data/spec/unit/translations_spec.rb +5 -5
- data/spec/unit/typecast_spec.rb +131 -131
- data/spec/unit/utils/migrate_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +31 -31
- metadata +27 -12
- data/lib/couchrest/model/casted_hash.rb +0 -84
@@ -56,16 +56,16 @@ describe CouchRest::Model::Embeddable do
|
|
56
56
|
end
|
57
57
|
it "should automatically include the property mixin and define getters and setters" do
|
58
58
|
@obj.name = 'Matt'
|
59
|
-
@obj.name.
|
59
|
+
expect(@obj.name).to eq('Matt')
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should allow override of default" do
|
63
63
|
@obj = WithCastedModelMixin.new(:name => 'Eric', :details => {'color' => 'orange'})
|
64
|
-
@obj.name.
|
65
|
-
@obj.details['color'].
|
64
|
+
expect(@obj.name).to eq('Eric')
|
65
|
+
expect(@obj.details['color']).to eq('orange')
|
66
66
|
end
|
67
67
|
it "should always return base_doc? as false" do
|
68
|
-
@obj.base_doc
|
68
|
+
expect(@obj.base_doc?).to be_falsey
|
69
69
|
end
|
70
70
|
it "should call after_initialize callback if available" do
|
71
71
|
klass = Class.new do
|
@@ -75,7 +75,7 @@ describe CouchRest::Model::Embeddable do
|
|
75
75
|
def set_name; self.name = "foobar"; end
|
76
76
|
end
|
77
77
|
@obj = klass.new
|
78
|
-
@obj.name.
|
78
|
+
expect(@obj.name).to eql("foobar")
|
79
79
|
end
|
80
80
|
it "should allow override of initialize with super" do
|
81
81
|
klass = Class.new do
|
@@ -86,7 +86,7 @@ describe CouchRest::Model::Embeddable do
|
|
86
86
|
def initialize(attrs = {}); super(); end
|
87
87
|
end
|
88
88
|
@obj = klass.new
|
89
|
-
@obj.name.
|
89
|
+
expect(@obj.name).to eql("foobar")
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -96,7 +96,7 @@ describe CouchRest::Model::Embeddable do
|
|
96
96
|
@casted_obj = @obj.casted_attribute
|
97
97
|
end
|
98
98
|
it "should be nil" do
|
99
|
-
@casted_obj.
|
99
|
+
expect(@casted_obj).to eq(nil)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -105,20 +105,20 @@ describe CouchRest::Model::Embeddable do
|
|
105
105
|
@obj = DummyModel.new
|
106
106
|
end
|
107
107
|
it "should be empty initially" do
|
108
|
-
@obj.sub_models.
|
109
|
-
@obj.sub_models.
|
108
|
+
expect(@obj.sub_models).not_to be_nil
|
109
|
+
expect(@obj.sub_models).to be_empty
|
110
110
|
end
|
111
111
|
it "should be updatable using a hash" do
|
112
112
|
@obj.sub_models << {:title => 'test'}
|
113
|
-
@obj.sub_models.first.title.
|
113
|
+
expect(@obj.sub_models.first.title).to eql('test')
|
114
114
|
end
|
115
115
|
it "should be empty intitally (without params)" do
|
116
|
-
@obj.param_free_sub_models.
|
117
|
-
@obj.param_free_sub_models.
|
116
|
+
expect(@obj.param_free_sub_models).not_to be_nil
|
117
|
+
expect(@obj.param_free_sub_models).to be_empty
|
118
118
|
end
|
119
119
|
it "should be updatable using a hash (without params)" do
|
120
120
|
@obj.param_free_sub_models << {:title => 'test'}
|
121
|
-
@obj.param_free_sub_models.first.title.
|
121
|
+
expect(@obj.param_free_sub_models.first.title).to eql('test')
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -130,35 +130,35 @@ describe CouchRest::Model::Embeddable do
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should be available from its parent" do
|
133
|
-
@casted_obj.
|
133
|
+
expect(@casted_obj).to be_an_instance_of(WithCastedModelMixin)
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should have the getters defined" do
|
137
|
-
@casted_obj.name.
|
137
|
+
expect(@casted_obj.name).to eq('whatever')
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should know who casted it" do
|
141
|
-
@casted_obj.casted_by.
|
141
|
+
expect(@casted_obj.casted_by).to eq(@obj)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should know which property casted it" do
|
145
|
-
@casted_obj.casted_by_property.
|
145
|
+
expect(@casted_obj.casted_by_property).to eq(@obj.properties.detect{|p| p.to_s == 'casted_attribute'})
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should return nil for the 'no_value' attribute" do
|
149
|
-
@casted_obj.no_value.
|
149
|
+
expect(@casted_obj.no_value).to be_nil
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should return nil for the unknown attribute" do
|
153
|
-
@casted_obj["unknown"].
|
153
|
+
expect(@casted_obj["unknown"]).to be_nil
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should return {} for the hash attribute" do
|
157
|
-
@casted_obj.details.
|
157
|
+
expect(@casted_obj.details).to eq({})
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should cast its own attributes" do
|
161
|
-
@casted_obj.casted_attribute.
|
161
|
+
expect(@casted_obj.casted_attribute).to be_instance_of(WithCastedModelMixin)
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should raise an error if save or update_attributes called" do
|
@@ -174,23 +174,23 @@ describe CouchRest::Model::Embeddable do
|
|
174
174
|
@casted_obj = @obj.old_casted_attribute
|
175
175
|
end
|
176
176
|
it "should be available from its parent" do
|
177
|
-
@casted_obj.
|
177
|
+
expect(@casted_obj).to be_an_instance_of(OldFashionedMixin)
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should have the getters defined" do
|
181
|
-
@casted_obj.name.
|
181
|
+
expect(@casted_obj.name).to eq('Testing')
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should know who casted it" do
|
185
|
-
@casted_obj.casted_by.
|
185
|
+
expect(@casted_obj.casted_by).to eq(@obj)
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should know which property casted it" do
|
189
|
-
@casted_obj.casted_by_property.
|
189
|
+
expect(@casted_obj.casted_by_property).to eq(@obj.properties.detect{|p| p.to_s == 'old_casted_attribute'})
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should return nil for the unknown attribute" do
|
193
|
-
@casted_obj["unknown"].
|
193
|
+
expect(@casted_obj["unknown"]).to be_nil
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -200,8 +200,8 @@ describe CouchRest::Model::Embeddable do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should cast the array properly" do
|
203
|
-
@obj.keywords.
|
204
|
-
@obj.keywords.first.
|
203
|
+
expect(@obj.keywords).to be_kind_of(Array)
|
204
|
+
expect(@obj.keywords.first).to eq('couch')
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -209,33 +209,35 @@ describe CouchRest::Model::Embeddable do
|
|
209
209
|
before(:each) do
|
210
210
|
@question = Question.new(:q => "What is your quest?", :a => "To seek the Holy Grail")
|
211
211
|
end
|
212
|
-
it "should work for
|
213
|
-
@question.q.
|
214
|
-
@question['a'].
|
215
|
-
@question.
|
216
|
-
|
217
|
-
|
212
|
+
it "should work for write_attributes method" do
|
213
|
+
expect(@question.q).to eq("What is your quest?")
|
214
|
+
expect(@question['a']).to eq("To seek the Holy Grail")
|
215
|
+
@question.write_attributes(
|
216
|
+
:q => "What is your favorite color?", 'a' => "Blue"
|
217
|
+
)
|
218
|
+
expect(@question['q']).to eq("What is your favorite color?")
|
219
|
+
expect(@question.a).to eq("Blue")
|
218
220
|
end
|
219
221
|
|
220
222
|
it "should also work for attributes= alias" do
|
221
|
-
@question.respond_to?(:attributes=).
|
223
|
+
expect(@question.respond_to?(:attributes=)).to be_truthy
|
222
224
|
@question.attributes = {:q => "What is your favorite color?", 'a' => "Blue"}
|
223
|
-
@question['q'].
|
224
|
-
@question.a.
|
225
|
+
expect(@question['q']).to eq("What is your favorite color?")
|
226
|
+
expect(@question.a).to eq("Blue")
|
225
227
|
end
|
226
228
|
|
227
229
|
it "should flip out if an attribute= method is missing" do
|
228
|
-
|
229
|
-
@q.
|
230
|
-
}.
|
230
|
+
expect {
|
231
|
+
@q.attributes = { 'foo' => "something", :a => "No green" }
|
232
|
+
}.to raise_error(NoMethodError)
|
231
233
|
end
|
232
234
|
|
233
235
|
it "should not change any attributes if there is an error" do
|
234
|
-
|
235
|
-
@q.
|
236
|
-
}.
|
237
|
-
@question.q.
|
238
|
-
@question.a.
|
236
|
+
expect {
|
237
|
+
@q.attributes = { 'foo' => "something", :a => "No green" }
|
238
|
+
}.to raise_error(NoMethodError)
|
239
|
+
expect(@question.q).to eq("What is your quest?")
|
240
|
+
expect(@question.a).to eq("To seek the Holy Grail")
|
239
241
|
end
|
240
242
|
|
241
243
|
end
|
@@ -244,25 +246,25 @@ describe CouchRest::Model::Embeddable do
|
|
244
246
|
before(:each) do
|
245
247
|
reset_test_db!
|
246
248
|
@obj = DummyModel.new(:casted_attribute => {:name => 'whatever'})
|
247
|
-
@obj.save.
|
249
|
+
expect(@obj.save).to be_truthy
|
248
250
|
@obj = DummyModel.get(@obj.id)
|
249
251
|
end
|
250
252
|
|
251
253
|
it "should be able to load with the casted models" do
|
252
254
|
casted_obj = @obj.casted_attribute
|
253
|
-
casted_obj.
|
254
|
-
casted_obj.
|
255
|
+
expect(casted_obj).not_to be_nil
|
256
|
+
expect(casted_obj).to be_an_instance_of(WithCastedModelMixin)
|
255
257
|
end
|
256
258
|
|
257
259
|
it "should have defined getters for the casted model" do
|
258
260
|
casted_obj = @obj.casted_attribute
|
259
|
-
casted_obj.name.
|
261
|
+
expect(casted_obj.name).to eq("whatever")
|
260
262
|
end
|
261
263
|
|
262
264
|
it "should have defined setters for the casted model" do
|
263
265
|
casted_obj = @obj.casted_attribute
|
264
266
|
casted_obj.name = "test"
|
265
|
-
casted_obj.name.
|
267
|
+
expect(casted_obj.name).to eq("test")
|
266
268
|
end
|
267
269
|
|
268
270
|
it "should retain an override of a casted model attribute's default" do
|
@@ -270,7 +272,7 @@ describe CouchRest::Model::Embeddable do
|
|
270
272
|
casted_obj.details['color'] = 'orange'
|
271
273
|
@obj.save
|
272
274
|
casted_obj = DummyModel.get(@obj.id).casted_attribute
|
273
|
-
casted_obj.details['color'].
|
275
|
+
expect(casted_obj.details['color']).to eq('orange')
|
274
276
|
end
|
275
277
|
|
276
278
|
end
|
@@ -284,27 +286,27 @@ describe CouchRest::Model::Embeddable do
|
|
284
286
|
it "should save" do
|
285
287
|
toy = CatToy.new :name => "Mouse"
|
286
288
|
@cat.toys.push(toy)
|
287
|
-
@cat.save.
|
289
|
+
expect(@cat.save).to be_truthy
|
288
290
|
@cat = Cat.get @cat.id
|
289
|
-
@cat.toys.class.
|
290
|
-
@cat.toys.first.class.
|
291
|
-
@cat.toys.first.
|
291
|
+
expect(@cat.toys.class).to eq(CouchRest::Model::CastedArray)
|
292
|
+
expect(@cat.toys.first.class).to eq(CatToy)
|
293
|
+
expect(@cat.toys.first).to be === toy
|
292
294
|
end
|
293
295
|
|
294
296
|
it "should fail because name is not present" do
|
295
297
|
toy = CatToy.new
|
296
298
|
@cat.toys.push(toy)
|
297
|
-
@cat.
|
298
|
-
@cat.save.
|
299
|
+
expect(@cat).not_to be_valid
|
300
|
+
expect(@cat.save).to be_falsey
|
299
301
|
end
|
300
302
|
|
301
303
|
it "should not fail if the casted model doesn't have validation" do
|
302
304
|
Cat.property :masters, [Person], :default => []
|
303
305
|
Cat.validates_presence_of :name
|
304
306
|
cat = Cat.new(:name => 'kitty')
|
305
|
-
cat.
|
307
|
+
expect(cat).to be_valid
|
306
308
|
cat.masters.push Person.new
|
307
|
-
cat.
|
309
|
+
expect(cat).to be_valid
|
308
310
|
end
|
309
311
|
end
|
310
312
|
|
@@ -321,46 +323,46 @@ describe CouchRest::Model::Embeddable do
|
|
321
323
|
|
322
324
|
describe "on the top document" do
|
323
325
|
it "should put errors on all invalid casted models" do
|
324
|
-
@cat.
|
325
|
-
@cat.errors.
|
326
|
-
@toy1.errors.
|
327
|
-
@toy2.errors.
|
328
|
-
@toy3.errors.
|
326
|
+
expect(@cat).not_to be_valid
|
327
|
+
expect(@cat.errors).not_to be_empty
|
328
|
+
expect(@toy1.errors).not_to be_empty
|
329
|
+
expect(@toy2.errors).not_to be_empty
|
330
|
+
expect(@toy3.errors).not_to be_empty
|
329
331
|
end
|
330
332
|
|
331
333
|
it "should not put errors on valid casted models" do
|
332
334
|
@toy1.name = "Feather"
|
333
335
|
@toy2.name = "Twine"
|
334
|
-
@cat.
|
335
|
-
@cat.errors.
|
336
|
-
@toy1.errors.
|
337
|
-
@toy2.errors.
|
338
|
-
@toy3.errors.
|
336
|
+
expect(@cat).not_to be_valid
|
337
|
+
expect(@cat.errors).not_to be_empty
|
338
|
+
expect(@toy1.errors).to be_empty
|
339
|
+
expect(@toy2.errors).to be_empty
|
340
|
+
expect(@toy3.errors).not_to be_empty
|
339
341
|
end
|
340
342
|
|
341
343
|
it "should not use dperecated ActiveModel options" do
|
342
|
-
ActiveSupport::Deprecation.
|
343
|
-
@cat.
|
344
|
+
expect(ActiveSupport::Deprecation).not_to receive(:warn)
|
345
|
+
expect(@cat).not_to be_valid
|
344
346
|
end
|
345
347
|
end
|
346
348
|
|
347
349
|
describe "on a casted model property" do
|
348
350
|
it "should only validate itself" do
|
349
|
-
@toy1.
|
350
|
-
@toy1.errors.
|
351
|
-
@cat.errors.
|
352
|
-
@toy2.errors.
|
353
|
-
@toy3.errors.
|
351
|
+
expect(@toy1).not_to be_valid
|
352
|
+
expect(@toy1.errors).not_to be_empty
|
353
|
+
expect(@cat.errors).to be_empty
|
354
|
+
expect(@toy2.errors).to be_empty
|
355
|
+
expect(@toy3.errors).to be_empty
|
354
356
|
end
|
355
357
|
end
|
356
358
|
|
357
359
|
describe "on a casted model inside a casted collection" do
|
358
360
|
it "should only validate itself" do
|
359
|
-
@toy2.
|
360
|
-
@toy2.errors.
|
361
|
-
@cat.errors.
|
362
|
-
@toy1.errors.
|
363
|
-
@toy3.errors.
|
361
|
+
expect(@toy2).not_to be_valid
|
362
|
+
expect(@toy2.errors).not_to be_empty
|
363
|
+
expect(@cat.errors).to be_empty
|
364
|
+
expect(@toy1.errors).to be_empty
|
365
|
+
expect(@toy3.errors).to be_empty
|
364
366
|
end
|
365
367
|
end
|
366
368
|
end
|
@@ -375,37 +377,37 @@ describe CouchRest::Model::Embeddable do
|
|
375
377
|
end
|
376
378
|
|
377
379
|
it "should be true on new" do
|
378
|
-
CatToy.new.
|
379
|
-
CatToy.new.new_record
|
380
|
+
expect(CatToy.new).to be_new
|
381
|
+
expect(CatToy.new.new_record?).to be_truthy
|
380
382
|
end
|
381
383
|
|
382
384
|
it "should be true after assignment" do
|
383
|
-
@cat.
|
384
|
-
@cat.favorite_toy.
|
385
|
-
@cat.toys.first.
|
385
|
+
expect(@cat).to be_new
|
386
|
+
expect(@cat.favorite_toy).to be_new
|
387
|
+
expect(@cat.toys.first).to be_new
|
386
388
|
end
|
387
389
|
|
388
390
|
it "should not be true after create or save" do
|
389
391
|
@cat.create
|
390
392
|
@cat.save
|
391
|
-
@cat.favorite_toy.
|
392
|
-
@cat.toys.first.casted_by.
|
393
|
-
@cat.toys.first.
|
393
|
+
expect(@cat.favorite_toy).not_to be_new
|
394
|
+
expect(@cat.toys.first.casted_by).to eql(@cat)
|
395
|
+
expect(@cat.toys.first).not_to be_new
|
394
396
|
end
|
395
397
|
|
396
398
|
it "should not be true after get from the database" do
|
397
399
|
@cat.save
|
398
400
|
@cat = Cat.get(@cat.id)
|
399
|
-
@cat.favorite_toy.
|
400
|
-
@cat.toys.first.
|
401
|
+
expect(@cat.favorite_toy).not_to be_new
|
402
|
+
expect(@cat.toys.first).not_to be_new
|
401
403
|
end
|
402
404
|
|
403
405
|
it "should still be true after a failed create or save" do
|
404
406
|
@cat.name = nil
|
405
|
-
@cat.create.
|
406
|
-
@cat.save.
|
407
|
-
@cat.favorite_toy.
|
408
|
-
@cat.toys.first.
|
407
|
+
expect(@cat.create).to be_falsey
|
408
|
+
expect(@cat.save).to be_falsey
|
409
|
+
expect(@cat.favorite_toy).to be_new
|
410
|
+
expect(@cat.toys.first).to be_new
|
409
411
|
end
|
410
412
|
end
|
411
413
|
|
@@ -427,27 +429,27 @@ describe CouchRest::Model::Embeddable do
|
|
427
429
|
@course.questions << question
|
428
430
|
new_course = Course.new
|
429
431
|
new_course.questions = @course.questions
|
430
|
-
new_course.questions.
|
432
|
+
expect(new_course.questions).to include(question)
|
431
433
|
end
|
432
434
|
|
433
435
|
it "should reference the top document for" do
|
434
|
-
@course.base_doc.
|
435
|
-
@professor.casted_by.
|
436
|
-
@professor.base_doc.
|
437
|
-
@cat.base_doc.
|
438
|
-
@toy1.base_doc.
|
439
|
-
@toy2.base_doc.
|
436
|
+
expect(@course.base_doc).to be === @course
|
437
|
+
expect(@professor.casted_by).to be === @course
|
438
|
+
expect(@professor.base_doc).to be === @course
|
439
|
+
expect(@cat.base_doc).to be === @course
|
440
|
+
expect(@toy1.base_doc).to be === @course
|
441
|
+
expect(@toy2.base_doc).to be === @course
|
440
442
|
end
|
441
443
|
|
442
444
|
it "should call setter on top document" do
|
443
|
-
@toy1.base_doc.
|
445
|
+
expect(@toy1.base_doc).not_to be_nil
|
444
446
|
@toy1.base_doc.title = 'Tom Foolery'
|
445
|
-
@course.title.
|
447
|
+
expect(@course.title).to eq('Tom Foolery')
|
446
448
|
end
|
447
449
|
|
448
450
|
it "should return nil if not yet casted" do
|
449
451
|
person = Person.new
|
450
|
-
person.base_doc.
|
452
|
+
expect(person.base_doc).to eq(nil)
|
451
453
|
end
|
452
454
|
end
|
453
455
|
|
@@ -460,16 +462,16 @@ describe CouchRest::Model::Embeddable do
|
|
460
462
|
end
|
461
463
|
|
462
464
|
it "should not save parent document when casted model is invalid" do
|
463
|
-
@toy.
|
464
|
-
@toy.base_doc.save.
|
465
|
-
|
465
|
+
expect(@toy).not_to be_valid
|
466
|
+
expect(@toy.base_doc.save).to be_falsey
|
467
|
+
expect{@toy.base_doc.save!}.to raise_error(/Validation Failed/)
|
466
468
|
end
|
467
469
|
|
468
470
|
it "should save parent document when nested casted model is valid" do
|
469
471
|
@toy.name = "Mr Squeaks"
|
470
|
-
@toy.
|
471
|
-
@toy.base_doc.save.
|
472
|
-
|
472
|
+
expect(@toy).to be_valid
|
473
|
+
expect(@toy.base_doc.save).to be_truthy
|
474
|
+
expect{@toy.base_doc.save!}.not_to raise_error
|
473
475
|
end
|
474
476
|
end
|
475
477
|
|
@@ -482,14 +484,14 @@ describe CouchRest::Model::Embeddable do
|
|
482
484
|
|
483
485
|
describe "validate" do
|
484
486
|
it "should run before_validation before validating" do
|
485
|
-
@model.run_before_validation.
|
486
|
-
@model.
|
487
|
-
@model.run_before_validation.
|
487
|
+
expect(@model.run_before_validation).to be_nil
|
488
|
+
expect(@model).to be_valid
|
489
|
+
expect(@model.run_before_validation).to be_truthy
|
488
490
|
end
|
489
491
|
it "should run after_validation after validating" do
|
490
|
-
@model.run_after_validation.
|
491
|
-
@model.
|
492
|
-
@model.run_after_validation.
|
492
|
+
expect(@model.run_after_validation).to be_nil
|
493
|
+
expect(@model).to be_valid
|
494
|
+
expect(@model.run_after_validation).to be_truthy
|
493
495
|
end
|
494
496
|
end
|
495
497
|
end
|