ardm 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/Gemfile +14 -2
- data/ardm.gemspec +1 -1
- data/lib/ardm.rb +8 -0
- data/lib/ardm/active_record.rb +0 -5
- data/lib/ardm/active_record/associations.rb +27 -10
- data/lib/ardm/active_record/predicate_builder/rails4.rb +12 -5
- data/lib/ardm/active_record/property.rb +4 -3
- data/lib/ardm/active_record/record.rb +10 -6
- data/lib/ardm/active_record/relation.rb +67 -2
- data/lib/ardm/data_mapper.rb +2 -0
- data/lib/ardm/data_mapper/record.rb +19 -22
- data/lib/ardm/property/support/paranoid_base.rb +1 -1
- data/lib/ardm/query/expression.rb +5 -15
- data/lib/ardm/query/operator.rb +3 -3
- data/lib/ardm/version.rb +1 -1
- data/spec/fixtures/article.rb +1 -1
- data/spec/fixtures/resource_blog.rb +53 -0
- data/spec/integration/comma_separated_list_spec.rb +4 -4
- data/spec/integration/dirty_minder_spec.rb +1 -1
- data/spec/integration/enum_spec.rb +2 -2
- data/spec/integration/epoch_time_spec.rb +2 -2
- data/spec/integration/file_path_spec.rb +4 -4
- data/spec/integration/flag_spec.rb +5 -3
- data/spec/integration/json_spec.rb +3 -3
- data/spec/public/model_spec.rb +78 -8
- data/spec/public/property_spec.rb +10 -6
- data/spec/public/resource_spec.rb +9 -64
- data/spec/shared/{finder_shared_spec.rb → finder_shared.rb} +134 -128
- data/spec/shared/{flags_shared_spec.rb → flags_shared.rb} +0 -0
- data/spec/shared/{public_property_spec.rb → public_property.rb} +0 -0
- data/spec/shared/{resource_spec.rb → resource.rb} +46 -31
- data/spec/shared/{semipublic_property_spec.rb → semipublic_property.rb} +0 -0
- data/spec/spec_helper.rb +11 -5
- data/spec/support/logger.rb +38 -0
- data/spec/unit/dirty_minder_spec.rb +4 -2
- data/spec/unit/paranoid_boolean_spec.rb +3 -3
- data/spec/unit/paranoid_datetime_spec.rb +3 -3
- metadata +59 -30
- checksums.yaml +0 -7
@@ -12,7 +12,7 @@ shared_examples 'Finder Interface' do
|
|
12
12
|
|
13
13
|
@do_adapter = defined?(Ardm::Adapters::DataObjectsAdapter) && @adapter.kind_of?(Ardm::Adapters::DataObjectsAdapter)
|
14
14
|
|
15
|
-
|
15
|
+
@many_to_many = false
|
16
16
|
|
17
17
|
@skip = @no_join && @many_to_many
|
18
18
|
end
|
@@ -21,7 +21,11 @@ shared_examples 'Finder Interface' do
|
|
21
21
|
skip if @skip
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
def skip_if(message=nil, condition)
|
25
|
+
skip(message) if condition
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should be Enumerable', :dm do
|
25
29
|
expect(@articles).to be_kind_of(Enumerable)
|
26
30
|
end
|
27
31
|
|
@@ -55,15 +59,16 @@ shared_examples 'Finder Interface' do
|
|
55
59
|
@return = @resources = @articles.send(method, 5, 5)
|
56
60
|
end
|
57
61
|
|
58
|
-
it 'should return a Collection' do
|
62
|
+
it 'should return a Collection', :dm do
|
59
63
|
expect(@return).to be_kind_of(Ardm::Collection)
|
64
|
+
@return.should be_kind_of(Ardm::Collection)
|
60
65
|
end
|
61
66
|
|
62
67
|
it 'should return the expected Resource' do
|
63
68
|
expect(@return).to eq(@copy.entries.send(method, 5, 5))
|
64
69
|
end
|
65
70
|
|
66
|
-
it 'should scope the Collection' do
|
71
|
+
it 'should scope the Collection', :dm do
|
67
72
|
expect(@resources.reload).to eq(@copy.entries.send(method, 5, 5))
|
68
73
|
end
|
69
74
|
end
|
@@ -73,7 +78,7 @@ shared_examples 'Finder Interface' do
|
|
73
78
|
@return = @resources = @articles.send(method, 5..10)
|
74
79
|
end
|
75
80
|
|
76
|
-
it 'should return a Collection' do
|
81
|
+
it 'should return a Collection', :dm do
|
77
82
|
expect(@return).to be_kind_of(Ardm::Collection)
|
78
83
|
end
|
79
84
|
|
@@ -81,7 +86,7 @@ shared_examples 'Finder Interface' do
|
|
81
86
|
expect(@return).to eq(@copy.entries.send(method, 5..10))
|
82
87
|
end
|
83
88
|
|
84
|
-
it 'should scope the Collection' do
|
89
|
+
it 'should scope the Collection', :dm do
|
85
90
|
expect(@resources.reload).to eq(@copy.entries.send(method, 5..10))
|
86
91
|
end
|
87
92
|
end
|
@@ -107,7 +112,7 @@ shared_examples 'Finder Interface' do
|
|
107
112
|
@return = @resources = @articles.send(method, -5, 5)
|
108
113
|
end
|
109
114
|
|
110
|
-
it 'should return a Collection' do
|
115
|
+
it 'should return a Collection', :dm do
|
111
116
|
expect(@return).to be_kind_of(Ardm::Collection)
|
112
117
|
end
|
113
118
|
|
@@ -115,7 +120,7 @@ shared_examples 'Finder Interface' do
|
|
115
120
|
expect(@return).to eq(@copy.entries.send(method, -5, 5))
|
116
121
|
end
|
117
122
|
|
118
|
-
it 'should scope the Collection' do
|
123
|
+
it 'should scope the Collection', :dm do
|
119
124
|
expect(@resources.reload).to eq(@copy.entries.send(method, -5, 5))
|
120
125
|
end
|
121
126
|
end
|
@@ -125,7 +130,7 @@ shared_examples 'Finder Interface' do
|
|
125
130
|
@return = @resources = @articles.send(method, -5..-2)
|
126
131
|
end
|
127
132
|
|
128
|
-
it 'should return a Collection' do
|
133
|
+
it 'should return a Collection', :dm do
|
129
134
|
expect(@return).to be_kind_of(Ardm::Collection)
|
130
135
|
end
|
131
136
|
|
@@ -133,7 +138,7 @@ shared_examples 'Finder Interface' do
|
|
133
138
|
expect(@return.to_a).to eq(@copy.entries.send(method, -5..-2))
|
134
139
|
end
|
135
140
|
|
136
|
-
it 'should scope the Collection' do
|
141
|
+
it 'should scope the Collection', :dm do
|
137
142
|
expect(@resources.reload).to eq(@copy.entries.send(method, -5..-2))
|
138
143
|
end
|
139
144
|
end
|
@@ -143,7 +148,7 @@ shared_examples 'Finder Interface' do
|
|
143
148
|
@return = @resources = @articles.send(method, 0...0)
|
144
149
|
end
|
145
150
|
|
146
|
-
it 'should return a Collection' do
|
151
|
+
it 'should return a Collection', :dm do
|
147
152
|
expect(@return).to be_kind_of(Ardm::Collection)
|
148
153
|
end
|
149
154
|
|
@@ -168,7 +173,7 @@ shared_examples 'Finder Interface' do
|
|
168
173
|
end
|
169
174
|
end
|
170
175
|
|
171
|
-
describe 'with an offset and length not within the Collection' do
|
176
|
+
describe 'with an offset and length not within the Collection', :dm do
|
172
177
|
before do
|
173
178
|
@return = @articles.send(method, 99, 1)
|
174
179
|
end
|
@@ -182,7 +187,7 @@ shared_examples 'Finder Interface' do
|
|
182
187
|
end
|
183
188
|
end
|
184
189
|
|
185
|
-
describe 'with a range not within the Collection' do
|
190
|
+
describe 'with a range not within the Collection', :dm do
|
186
191
|
before do
|
187
192
|
@return = @articles.send(method, 99..100)
|
188
193
|
end
|
@@ -208,7 +213,7 @@ shared_examples 'Finder Interface' do
|
|
208
213
|
@return = @collection = @articles.all
|
209
214
|
end
|
210
215
|
|
211
|
-
it 'should return a Collection' do
|
216
|
+
it 'should return a Collection', :dm do
|
212
217
|
expect(@return).to be_kind_of(Ardm::Collection)
|
213
218
|
end
|
214
219
|
|
@@ -220,11 +225,11 @@ shared_examples 'Finder Interface' do
|
|
220
225
|
expect(@collection).to eq(@articles.entries)
|
221
226
|
end
|
222
227
|
|
223
|
-
it 'should not have a Query the same as the original' do
|
228
|
+
it 'should not have a Query the same as the original', :dm do
|
224
229
|
expect(@return.query).not_to equal(@articles.query)
|
225
230
|
end
|
226
231
|
|
227
|
-
it 'should have a Query equal to the original' do
|
232
|
+
it 'should have a Query equal to the original', :dm do
|
228
233
|
expect(@return.query).to eql(@articles.query)
|
229
234
|
end
|
230
235
|
|
@@ -241,7 +246,7 @@ shared_examples 'Finder Interface' do
|
|
241
246
|
@return = @articles.all(:body => [ 'New Article' ])
|
242
247
|
end
|
243
248
|
|
244
|
-
it 'should return a Collection' do
|
249
|
+
it 'should return a Collection', :dm do
|
245
250
|
expect(@return).to be_kind_of(Ardm::Collection)
|
246
251
|
end
|
247
252
|
|
@@ -253,7 +258,7 @@ shared_examples 'Finder Interface' do
|
|
253
258
|
expect(@return).to eq([ @new ])
|
254
259
|
end
|
255
260
|
|
256
|
-
it 'should have a different query than original Collection' do
|
261
|
+
it 'should have a different query than original Collection', :dm do
|
257
262
|
expect(@return.query).not_to equal(@articles.query)
|
258
263
|
end
|
259
264
|
|
@@ -274,7 +279,7 @@ shared_examples 'Finder Interface' do
|
|
274
279
|
@return = @articles.all(:conditions => [ 'subtitle = ?', 'New Article' ])
|
275
280
|
end
|
276
281
|
|
277
|
-
it 'should return a Collection' do
|
282
|
+
it 'should return a Collection', :dm do
|
278
283
|
expect(@return).to be_kind_of(Ardm::Collection)
|
279
284
|
end
|
280
285
|
|
@@ -295,7 +300,7 @@ shared_examples 'Finder Interface' do
|
|
295
300
|
end
|
296
301
|
end
|
297
302
|
|
298
|
-
describe 'with a query that is out of range' do
|
303
|
+
describe 'with a query that is out of range', :dm do
|
299
304
|
it 'should raise an exception' do
|
300
305
|
expect {
|
301
306
|
@articles.all(:limit => 10).all(:offset => 10)
|
@@ -309,7 +314,7 @@ shared_examples 'Finder Interface' do
|
|
309
314
|
@return = @articles.all(:original => @original.attributes)
|
310
315
|
end
|
311
316
|
|
312
|
-
it 'should return a Collection' do
|
317
|
+
it 'should return a Collection', :dm do
|
313
318
|
expect(@return).to be_kind_of(Ardm::Collection)
|
314
319
|
end
|
315
320
|
|
@@ -317,7 +322,7 @@ shared_examples 'Finder Interface' do
|
|
317
322
|
expect(@return).to eq([ @article ])
|
318
323
|
end
|
319
324
|
|
320
|
-
it 'should have a valid query' do
|
325
|
+
it 'should have a valid query', :dm do
|
321
326
|
expect(@return.query).to be_valid
|
322
327
|
end
|
323
328
|
end
|
@@ -327,7 +332,7 @@ shared_examples 'Finder Interface' do
|
|
327
332
|
@return = @articles.all(:original => @original)
|
328
333
|
end
|
329
334
|
|
330
|
-
it 'should return a Collection' do
|
335
|
+
it 'should return a Collection', :dm do
|
331
336
|
expect(@return).to be_kind_of(Ardm::Collection)
|
332
337
|
end
|
333
338
|
|
@@ -335,7 +340,7 @@ shared_examples 'Finder Interface' do
|
|
335
340
|
expect(@return).to eq([ @article ])
|
336
341
|
end
|
337
342
|
|
338
|
-
it 'should have a valid query' do
|
343
|
+
it 'should have a valid query', :dm do
|
339
344
|
expect(@return.query).to be_valid
|
340
345
|
end
|
341
346
|
end
|
@@ -349,7 +354,7 @@ shared_examples 'Finder Interface' do
|
|
349
354
|
@return = @articles.all(:original => @collection)
|
350
355
|
end
|
351
356
|
|
352
|
-
it 'should return a Collection' do
|
357
|
+
it 'should return a Collection', :dm do
|
353
358
|
expect(@return).to be_kind_of(Ardm::Collection)
|
354
359
|
end
|
355
360
|
|
@@ -357,7 +362,7 @@ shared_examples 'Finder Interface' do
|
|
357
362
|
expect(@return).to eq([ @article ])
|
358
363
|
end
|
359
364
|
|
360
|
-
it 'should have a valid query' do
|
365
|
+
it 'should have a valid query', :dm do
|
361
366
|
expect(@return.query).to be_valid
|
362
367
|
end
|
363
368
|
|
@@ -368,7 +373,7 @@ shared_examples 'Finder Interface' do
|
|
368
373
|
@return = @articles.all(:original => [])
|
369
374
|
end
|
370
375
|
|
371
|
-
it 'should return a Collection' do
|
376
|
+
it 'should return a Collection', :dm do
|
372
377
|
expect(@return).to be_kind_of(Ardm::Collection)
|
373
378
|
end
|
374
379
|
|
@@ -376,7 +381,7 @@ shared_examples 'Finder Interface' do
|
|
376
381
|
expect(@return).to be_empty
|
377
382
|
end
|
378
383
|
|
379
|
-
it 'should not have a valid query' do
|
384
|
+
it 'should not have a valid query', :dm do
|
380
385
|
expect(@return.query).not_to be_valid
|
381
386
|
end
|
382
387
|
end
|
@@ -386,32 +391,26 @@ shared_examples 'Finder Interface' do
|
|
386
391
|
@return = @articles.all(:original => nil)
|
387
392
|
end
|
388
393
|
|
389
|
-
it 'should return a Collection' do
|
394
|
+
it 'should return a Collection', :dm do
|
390
395
|
expect(@return).to be_kind_of(Ardm::Collection)
|
391
396
|
end
|
392
397
|
|
393
|
-
|
394
|
-
|
395
|
-
expect(@return).to eq([ @original, @other ])
|
396
|
-
end
|
397
|
-
else
|
398
|
-
it 'should be an empty Collection' do
|
399
|
-
expect(@return).to be_empty
|
400
|
-
end
|
398
|
+
it 'should be expected Resources' do
|
399
|
+
expect(@return).to eq([ @original ])
|
401
400
|
end
|
402
401
|
|
403
|
-
it 'should have a valid query' do
|
402
|
+
it 'should have a valid query', :dm do
|
404
403
|
expect(@return.query).to be_valid
|
405
404
|
end
|
406
405
|
|
407
406
|
it 'should be equivalent to negated collection query' do
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
407
|
+
skip_if 'Update RDBMS to match ruby behavior', @do_adapter && @articles.kind_of?(Ardm::Record) do
|
408
|
+
# NOTE: the second query will not match any articles where original_id
|
409
|
+
# is nil, while the in-memory/yaml adapters will. RDBMS will explicitly
|
410
|
+
# filter out NULL matches because we are matching on a non-NULL value,
|
411
|
+
# which is not consistent with how DM/Ruby matching behaves.
|
412
|
+
expect(@return).to eq(@articles.all(:original.not => @article_model.all))
|
413
|
+
end
|
415
414
|
end
|
416
415
|
end
|
417
416
|
|
@@ -420,7 +419,7 @@ shared_examples 'Finder Interface' do
|
|
420
419
|
@return = @articles.all(:original.not => nil)
|
421
420
|
end
|
422
421
|
|
423
|
-
it 'should return a Collection' do
|
422
|
+
it 'should return a Collection', :dm do
|
424
423
|
expect(@return).to be_kind_of(Ardm::Collection)
|
425
424
|
end
|
426
425
|
|
@@ -428,7 +427,7 @@ shared_examples 'Finder Interface' do
|
|
428
427
|
expect(@return).to eq([ @article ])
|
429
428
|
end
|
430
429
|
|
431
|
-
it 'should have a valid query' do
|
430
|
+
it 'should have a valid query', :dm do
|
432
431
|
expect(@return.query).to be_valid
|
433
432
|
end
|
434
433
|
|
@@ -448,7 +447,7 @@ shared_examples 'Finder Interface' do
|
|
448
447
|
@return = @articles.all(:previous => @new.attributes)
|
449
448
|
end
|
450
449
|
|
451
|
-
it 'should return a Collection' do
|
450
|
+
it 'should return a Collection', :dm do
|
452
451
|
expect(@return).to be_kind_of(Ardm::Collection)
|
453
452
|
end
|
454
453
|
|
@@ -456,7 +455,7 @@ shared_examples 'Finder Interface' do
|
|
456
455
|
expect(@return).to eq([ @article ])
|
457
456
|
end
|
458
457
|
|
459
|
-
it 'should have a valid query' do
|
458
|
+
it 'should have a valid query', :dm do
|
460
459
|
expect(@return.query).to be_valid
|
461
460
|
end
|
462
461
|
end
|
@@ -466,7 +465,7 @@ shared_examples 'Finder Interface' do
|
|
466
465
|
@return = @articles.all(:previous => @new)
|
467
466
|
end
|
468
467
|
|
469
|
-
it 'should return a Collection' do
|
468
|
+
it 'should return a Collection', :dm do
|
470
469
|
expect(@return).to be_kind_of(Ardm::Collection)
|
471
470
|
end
|
472
471
|
|
@@ -474,7 +473,7 @@ shared_examples 'Finder Interface' do
|
|
474
473
|
expect(@return).to eq([ @article ])
|
475
474
|
end
|
476
475
|
|
477
|
-
it 'should have a valid query' do
|
476
|
+
it 'should have a valid query', :dm do
|
478
477
|
expect(@return.query).to be_valid
|
479
478
|
end
|
480
479
|
end
|
@@ -488,7 +487,7 @@ shared_examples 'Finder Interface' do
|
|
488
487
|
@return = @articles.all(:previous => @collection)
|
489
488
|
end
|
490
489
|
|
491
|
-
it 'should return a Collection' do
|
490
|
+
it 'should return a Collection', :dm do
|
492
491
|
expect(@return).to be_kind_of(Ardm::Collection)
|
493
492
|
end
|
494
493
|
|
@@ -496,7 +495,7 @@ shared_examples 'Finder Interface' do
|
|
496
495
|
expect(@return).to eq([ @article ])
|
497
496
|
end
|
498
497
|
|
499
|
-
it 'should have a valid query' do
|
498
|
+
it 'should have a valid query', :dm do
|
500
499
|
expect(@return.query).to be_valid
|
501
500
|
end
|
502
501
|
end
|
@@ -506,7 +505,7 @@ shared_examples 'Finder Interface' do
|
|
506
505
|
@return = @articles.all(:previous => [])
|
507
506
|
end
|
508
507
|
|
509
|
-
it 'should return a Collection' do
|
508
|
+
it 'should return a Collection', :dm do
|
510
509
|
expect(@return).to be_kind_of(Ardm::Collection)
|
511
510
|
end
|
512
511
|
|
@@ -514,7 +513,7 @@ shared_examples 'Finder Interface' do
|
|
514
513
|
expect(@return).to be_empty
|
515
514
|
end
|
516
515
|
|
517
|
-
it 'should not have a valid query' do
|
516
|
+
it 'should not have a valid query', :dm do
|
518
517
|
expect(@return.query).not_to be_valid
|
519
518
|
end
|
520
519
|
end
|
@@ -524,7 +523,7 @@ shared_examples 'Finder Interface' do
|
|
524
523
|
@return = @articles.all(:previous => nil)
|
525
524
|
end
|
526
525
|
|
527
|
-
it 'should return a Collection' do
|
526
|
+
it 'should return a Collection', :dm do
|
528
527
|
expect(@return).to be_kind_of(Ardm::Collection)
|
529
528
|
end
|
530
529
|
|
@@ -538,11 +537,17 @@ shared_examples 'Finder Interface' do
|
|
538
537
|
end
|
539
538
|
end
|
540
539
|
|
541
|
-
it 'should have a valid query' do
|
540
|
+
it 'should have a valid query', :dm do
|
542
541
|
expect(@return.query).to be_valid
|
543
542
|
end
|
544
543
|
|
545
544
|
it 'should be equivalent to negated collection query' do
|
545
|
+
# SELECT "id", "title", "original_id" FROM "articles" WHERE NOT("id" IN (SELECT "original_id" FROM "articles" WHERE NOT("original_id" IS NULL))) ORDER BY "id"
|
546
|
+
# ar:
|
547
|
+
# SELECT "articles".* FROM "articles" WHERE ("articles"."original_id" IS NOT NULL)
|
548
|
+
# SELECT "articles".* FROM "articles" WHERE ("articles"."id" NOT IN (SELECT original_id FROM "articles" WHERE ("articles"."original_id" IS NOT NULL)))
|
549
|
+
puts "@return:#{@return.to_sql}"
|
550
|
+
puts "negated:#{@articles.all(:previous.not => @article_model.all(:original.not => nil)).to_sql}"
|
546
551
|
expect(@return).to eq(@articles.all(:previous.not => @article_model.all(:original.not => nil)))
|
547
552
|
end
|
548
553
|
end
|
@@ -552,21 +557,15 @@ shared_examples 'Finder Interface' do
|
|
552
557
|
@return = @articles.all(:previous.not => nil)
|
553
558
|
end
|
554
559
|
|
555
|
-
it 'should return a Collection' do
|
560
|
+
it 'should return a Collection', :dm do
|
556
561
|
expect(@return).to be_kind_of(Ardm::Collection)
|
557
562
|
end
|
558
563
|
|
559
|
-
|
560
|
-
|
561
|
-
expect(@return).to eq([ @original, @article ])
|
562
|
-
end
|
563
|
-
else
|
564
|
-
it 'should be expected Resources' do
|
565
|
-
expect(@return).to eq([ @article ])
|
566
|
-
end
|
564
|
+
it 'should be expected Resources' do
|
565
|
+
expect(@return).to eq([ @original, @article ])
|
567
566
|
end
|
568
567
|
|
569
|
-
it 'should have a valid query' do
|
568
|
+
it 'should have a valid query', :dm do
|
570
569
|
expect(@return.query).to be_valid
|
571
570
|
end
|
572
571
|
|
@@ -586,7 +585,7 @@ shared_examples 'Finder Interface' do
|
|
586
585
|
@return = @articles.all(:revisions => @new.attributes)
|
587
586
|
end
|
588
587
|
|
589
|
-
it 'should return a Collection' do
|
588
|
+
it 'should return a Collection', :dm do
|
590
589
|
expect(@return).to be_kind_of(Ardm::Collection)
|
591
590
|
end
|
592
591
|
|
@@ -594,7 +593,7 @@ shared_examples 'Finder Interface' do
|
|
594
593
|
expect(@return).to eq([ @article ])
|
595
594
|
end
|
596
595
|
|
597
|
-
it 'should have a valid query' do
|
596
|
+
it 'should have a valid query', :dm do
|
598
597
|
expect(@return.query).to be_valid
|
599
598
|
end
|
600
599
|
end
|
@@ -604,7 +603,7 @@ shared_examples 'Finder Interface' do
|
|
604
603
|
@return = @articles.all(:revisions => @new)
|
605
604
|
end
|
606
605
|
|
607
|
-
it 'should return a Collection' do
|
606
|
+
it 'should return a Collection', :dm do
|
608
607
|
expect(@return).to be_kind_of(Ardm::Collection)
|
609
608
|
end
|
610
609
|
|
@@ -612,7 +611,7 @@ shared_examples 'Finder Interface' do
|
|
612
611
|
expect(@return).to eq([ @article ])
|
613
612
|
end
|
614
613
|
|
615
|
-
it 'should have a valid query' do
|
614
|
+
it 'should have a valid query', :dm do
|
616
615
|
expect(@return.query).to be_valid
|
617
616
|
end
|
618
617
|
end
|
@@ -626,7 +625,7 @@ shared_examples 'Finder Interface' do
|
|
626
625
|
@return = @articles.all(:revisions => @collection)
|
627
626
|
end
|
628
627
|
|
629
|
-
it 'should return a Collection' do
|
628
|
+
it 'should return a Collection', :dm do
|
630
629
|
expect(@return).to be_kind_of(Ardm::Collection)
|
631
630
|
end
|
632
631
|
|
@@ -634,7 +633,7 @@ shared_examples 'Finder Interface' do
|
|
634
633
|
expect(@return).to eq([ @article ])
|
635
634
|
end
|
636
635
|
|
637
|
-
it 'should have a valid query' do
|
636
|
+
it 'should have a valid query', :dm do
|
638
637
|
expect(@return.query).to be_valid
|
639
638
|
end
|
640
639
|
end
|
@@ -644,7 +643,7 @@ shared_examples 'Finder Interface' do
|
|
644
643
|
@return = @articles.all(:revisions => [])
|
645
644
|
end
|
646
645
|
|
647
|
-
it 'should return a Collection' do
|
646
|
+
it 'should return a Collection', :dm do
|
648
647
|
expect(@return).to be_kind_of(Ardm::Collection)
|
649
648
|
end
|
650
649
|
|
@@ -662,7 +661,7 @@ shared_examples 'Finder Interface' do
|
|
662
661
|
@return = @articles.all(:revisions => nil)
|
663
662
|
end
|
664
663
|
|
665
|
-
it 'should return a Collection' do
|
664
|
+
it 'should return a Collection', :dm do
|
666
665
|
expect(@return).to be_kind_of(Ardm::Collection)
|
667
666
|
end
|
668
667
|
|
@@ -672,11 +671,12 @@ shared_examples 'Finder Interface' do
|
|
672
671
|
end
|
673
672
|
else
|
674
673
|
it 'should be expected Resources' do
|
674
|
+
# SELECT "id", "title", "original_id" FROM "articles" WHERE NOT("id" IN (SELECT "original_id" FROM "articles" WHERE NOT("original_id" IS NULL))) ORDER BY "id"
|
675
675
|
expect(@return).to eq([ @new ])
|
676
676
|
end
|
677
677
|
end
|
678
678
|
|
679
|
-
it 'should have a valid query' do
|
679
|
+
it 'should have a valid query', :dm do
|
680
680
|
expect(@return.query).to be_valid
|
681
681
|
end
|
682
682
|
|
@@ -690,21 +690,15 @@ shared_examples 'Finder Interface' do
|
|
690
690
|
@return = @articles.all(:revisions.not => nil)
|
691
691
|
end
|
692
692
|
|
693
|
-
it 'should return a Collection' do
|
693
|
+
it 'should return a Collection', :dm do
|
694
694
|
expect(@return).to be_kind_of(Ardm::Collection)
|
695
695
|
end
|
696
696
|
|
697
|
-
|
698
|
-
|
699
|
-
expect(@return).to eq([ @original, @article ])
|
700
|
-
end
|
701
|
-
else
|
702
|
-
it 'should be expected Resources' do
|
703
|
-
expect(@return).to eq([ @article ])
|
704
|
-
end
|
697
|
+
it 'should be expected Resources' do
|
698
|
+
expect(@return).to eq([ @original, @article ])
|
705
699
|
end
|
706
700
|
|
707
|
-
it 'should have a valid query' do
|
701
|
+
it 'should have a valid query', :dm do
|
708
702
|
expect(@return.query).to be_valid
|
709
703
|
end
|
710
704
|
|
@@ -724,16 +718,17 @@ shared_examples 'Finder Interface' do
|
|
724
718
|
@return = @articles.all(:publications => @publication.attributes)
|
725
719
|
end
|
726
720
|
|
727
|
-
it 'should return a Collection' do
|
721
|
+
it 'should return a Collection', :dm do
|
728
722
|
expect(@return).to be_kind_of(Ardm::Collection)
|
729
723
|
end
|
730
724
|
|
731
725
|
it 'should be expected Resources' do
|
732
|
-
skip 'TODO'
|
733
|
-
|
726
|
+
skip 'TODO' do
|
727
|
+
expect(@return).to eq([ @article ])
|
728
|
+
end
|
734
729
|
end
|
735
730
|
|
736
|
-
it 'should have a valid query' do
|
731
|
+
it 'should have a valid query', :dm do
|
737
732
|
expect(@return.query).to be_valid
|
738
733
|
end
|
739
734
|
end
|
@@ -743,16 +738,17 @@ shared_examples 'Finder Interface' do
|
|
743
738
|
@return = @articles.all(:publications => @publication)
|
744
739
|
end
|
745
740
|
|
746
|
-
it 'should return a Collection' do
|
741
|
+
it 'should return a Collection', :dm do
|
747
742
|
expect(@return).to be_kind_of(Ardm::Collection)
|
748
743
|
end
|
749
744
|
|
750
745
|
it 'should be expected Resources' do
|
751
|
-
skip 'TODO'
|
752
|
-
|
746
|
+
skip 'TODO' do
|
747
|
+
expect(@return).to eq([ @article ])
|
748
|
+
end
|
753
749
|
end
|
754
750
|
|
755
|
-
it 'should have a valid query' do
|
751
|
+
it 'should have a valid query', :dm do
|
756
752
|
expect(@return.query).to be_valid
|
757
753
|
end
|
758
754
|
end
|
@@ -766,16 +762,17 @@ shared_examples 'Finder Interface' do
|
|
766
762
|
@return = @articles.all(:publications => @collection)
|
767
763
|
end
|
768
764
|
|
769
|
-
it 'should return a Collection' do
|
765
|
+
it 'should return a Collection', :dm do
|
770
766
|
expect(@return).to be_kind_of(Ardm::Collection)
|
771
767
|
end
|
772
768
|
|
773
769
|
it 'should be expected Resources' do
|
774
|
-
skip 'TODO'
|
775
|
-
|
770
|
+
skip 'TODO' do
|
771
|
+
expect(@return).to eq([ @article ])
|
772
|
+
end
|
776
773
|
end
|
777
774
|
|
778
|
-
it 'should have a valid query' do
|
775
|
+
it 'should have a valid query', :dm do
|
779
776
|
expect(@return.query).to be_valid
|
780
777
|
end
|
781
778
|
end
|
@@ -785,7 +782,7 @@ shared_examples 'Finder Interface' do
|
|
785
782
|
@return = @articles.all(:publications => [])
|
786
783
|
end
|
787
784
|
|
788
|
-
it 'should return a Collection' do
|
785
|
+
it 'should return a Collection', :dm do
|
789
786
|
expect(@return).to be_kind_of(Ardm::Collection)
|
790
787
|
end
|
791
788
|
|
@@ -803,16 +800,17 @@ shared_examples 'Finder Interface' do
|
|
803
800
|
@return = @articles.all(:publications => nil)
|
804
801
|
end
|
805
802
|
|
806
|
-
it 'should return a Collection' do
|
803
|
+
it 'should return a Collection', :dm do
|
807
804
|
expect(@return).to be_kind_of(Ardm::Collection)
|
808
805
|
end
|
809
806
|
|
810
807
|
it 'should be empty' do
|
811
|
-
skip 'TODO'
|
812
|
-
|
808
|
+
skip 'TODO' do
|
809
|
+
expect(@return).to be_empty
|
810
|
+
end
|
813
811
|
end
|
814
812
|
|
815
|
-
it 'should have a valid query' do
|
813
|
+
it 'should have a valid query', :dm do
|
816
814
|
expect(@return.query).to be_valid
|
817
815
|
end
|
818
816
|
|
@@ -826,16 +824,17 @@ shared_examples 'Finder Interface' do
|
|
826
824
|
@return = @articles.all(:publications.not => nil)
|
827
825
|
end
|
828
826
|
|
829
|
-
it 'should return a Collection' do
|
827
|
+
it 'should return a Collection', :dm do
|
830
828
|
expect(@return).to be_kind_of(Ardm::Collection)
|
831
829
|
end
|
832
830
|
|
833
831
|
it 'should be expected Resources' do
|
834
|
-
skip 'TODO'
|
835
|
-
|
832
|
+
skip 'TODO' do
|
833
|
+
expect(@return).to eq([ @article ])
|
834
|
+
end
|
836
835
|
end
|
837
836
|
|
838
|
-
it 'should have a valid query' do
|
837
|
+
it 'should have a valid query', :dm do
|
839
838
|
expect(@return.query).to be_valid
|
840
839
|
end
|
841
840
|
|
@@ -931,18 +930,21 @@ shared_examples 'Finder Interface' do
|
|
931
930
|
end
|
932
931
|
|
933
932
|
it 'should respond to a belongs_to relationship method with #method_missing' do
|
934
|
-
|
935
|
-
|
933
|
+
skip_if 'Model#method_missing should delegate to relationships', @articles.kind_of?(Class) do
|
934
|
+
expect(@articles).to respond_to(:original)
|
935
|
+
end
|
936
936
|
end
|
937
937
|
|
938
938
|
it 'should respond to a has n relationship method with #method_missing' do
|
939
|
-
|
940
|
-
|
939
|
+
skip_if 'Model#method_missing should delegate to relationships', @articles.kind_of?(Class) do
|
940
|
+
expect(@articles).to respond_to(:revisions)
|
941
|
+
end
|
941
942
|
end
|
942
943
|
|
943
944
|
it 'should respond to a has 1 relationship method with #method_missing' do
|
944
|
-
|
945
|
-
|
945
|
+
skip_if 'Model#method_missing should delegate to relationships', @articles.kind_of?(Class) do
|
946
|
+
expect(@articles).to respond_to(:previous)
|
947
|
+
end
|
946
948
|
end
|
947
949
|
|
948
950
|
describe '#method_missing' do
|
@@ -959,7 +961,7 @@ shared_examples 'Finder Interface' do
|
|
959
961
|
end
|
960
962
|
end
|
961
963
|
|
962
|
-
it 'should return a Collection' do
|
964
|
+
it 'should return a Collection', :dm do
|
963
965
|
expect(@return).to be_kind_of(Ardm::Collection)
|
964
966
|
end
|
965
967
|
|
@@ -989,7 +991,7 @@ shared_examples 'Finder Interface' do
|
|
989
991
|
@return = @articles.previous
|
990
992
|
end
|
991
993
|
|
992
|
-
it 'should return a Collection' do
|
994
|
+
it 'should return a Collection', :dm do
|
993
995
|
expect(@return).to be_kind_of(Ardm::Collection)
|
994
996
|
end
|
995
997
|
|
@@ -1008,7 +1010,7 @@ shared_examples 'Finder Interface' do
|
|
1008
1010
|
@return = @articles.previous(:fields => [ :id ])
|
1009
1011
|
end
|
1010
1012
|
|
1011
|
-
it 'should return a Collection' do
|
1013
|
+
it 'should return a Collection', :dm do
|
1012
1014
|
expect(@return).to be_kind_of(Ardm::Collection)
|
1013
1015
|
end
|
1014
1016
|
|
@@ -1047,7 +1049,7 @@ shared_examples 'Finder Interface' do
|
|
1047
1049
|
@return = @collection = @articles.revisions
|
1048
1050
|
end
|
1049
1051
|
|
1050
|
-
it 'should return a Collection' do
|
1052
|
+
it 'should return a Collection', :dm do
|
1051
1053
|
expect(@return).to be_kind_of(Ardm::Collection)
|
1052
1054
|
end
|
1053
1055
|
|
@@ -1065,7 +1067,7 @@ shared_examples 'Finder Interface' do
|
|
1065
1067
|
@return = @collection = @articles.revisions(:fields => [ :id ])
|
1066
1068
|
end
|
1067
1069
|
|
1068
|
-
it 'should return a Collection' do
|
1070
|
+
it 'should return a Collection', :dm do
|
1069
1071
|
expect(@return).to be_kind_of(Ardm::Collection)
|
1070
1072
|
end
|
1071
1073
|
|
@@ -1098,18 +1100,20 @@ shared_examples 'Finder Interface' do
|
|
1098
1100
|
@return = @collection = @articles.publications
|
1099
1101
|
end
|
1100
1102
|
|
1101
|
-
it 'should return a Collection' do
|
1103
|
+
it 'should return a Collection', :dm do
|
1102
1104
|
expect(@return).to be_kind_of(Ardm::Collection)
|
1103
1105
|
end
|
1104
1106
|
|
1105
1107
|
it 'should return expected Collection' do
|
1106
|
-
|
1107
|
-
|
1108
|
+
skip_if @no_join do
|
1109
|
+
expect(@collection).to eq([ @publication1, @publication2 ])
|
1110
|
+
end
|
1108
1111
|
end
|
1109
1112
|
|
1110
1113
|
it 'should set the association for each Resource' do
|
1111
|
-
|
1112
|
-
|
1114
|
+
skip_if @no_join do
|
1115
|
+
expect(@articles.map { |resource| resource.publications }).to eq([ [ @publication1 ], [ @publication2 ] ])
|
1116
|
+
end
|
1113
1117
|
end
|
1114
1118
|
end
|
1115
1119
|
|
@@ -1118,13 +1122,14 @@ shared_examples 'Finder Interface' do
|
|
1118
1122
|
@return = @collection = @articles.publications(:fields => [ :id ])
|
1119
1123
|
end
|
1120
1124
|
|
1121
|
-
it 'should return a Collection' do
|
1125
|
+
it 'should return a Collection', :dm do
|
1122
1126
|
expect(@return).to be_kind_of(Ardm::Collection)
|
1123
1127
|
end
|
1124
1128
|
|
1125
1129
|
it 'should return expected Collection' do
|
1126
|
-
|
1127
|
-
|
1130
|
+
skip_if @no_join do
|
1131
|
+
expect(@collection).to eq([ @publication1, @publication2 ])
|
1132
|
+
end
|
1128
1133
|
end
|
1129
1134
|
|
1130
1135
|
{ :id => true, :name => false }.each do |attribute, expected|
|
@@ -1134,8 +1139,9 @@ shared_examples 'Finder Interface' do
|
|
1134
1139
|
end
|
1135
1140
|
|
1136
1141
|
it 'should set the association for each Resource' do
|
1137
|
-
|
1138
|
-
|
1142
|
+
skip_if @no_join do
|
1143
|
+
expect(@articles.map { |resource| resource.publications }).to eq([ [ @publication1 ], [ @publication2 ] ])
|
1144
|
+
end
|
1139
1145
|
end
|
1140
1146
|
end
|
1141
1147
|
end
|