pursuit 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pursuit/constants.rb +1 -1
- data/lib/pursuit/search.rb +18 -1
- data/spec/pursuit/search_spec.rb +234 -205
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1d45107d4ab3d9a2ac9d9eaf8451e6f75762f2c8ac71e51683c3afe98009c7
|
4
|
+
data.tar.gz: e40fa3f38548173ba042cd232347127a3059c4e7f4a417569cad81d16b2b3710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65009e855c743fad6e91b5939d59456c845976b2add94fd1d03a9603d34a6046d5e45e58dd3fc7ca33291600f1a17bb879b2c492f1d5c22102bc9f2124c591b3
|
7
|
+
data.tar.gz: 9662bc16e8eb17107089b5bdd7635a91d0647b71a015cff79bf43df4b517729036d8c9ff3fde2b299ca82e63e440b3abca2531eddaa35aeb306472e62a7bc708
|
data/Gemfile.lock
CHANGED
data/lib/pursuit/constants.rb
CHANGED
data/lib/pursuit/search.rb
CHANGED
@@ -90,7 +90,7 @@ module Pursuit
|
|
90
90
|
|
91
91
|
def build_arel_for_reflection(reflection, attribute_names, operator, value)
|
92
92
|
nodes = build_arel_for_reflection_join(reflection)
|
93
|
-
count_nodes = build_arel_for_relation_count(nodes, operator, value)
|
93
|
+
count_nodes = build_arel_for_relation_count(nodes, operator, value) unless reflection.belongs_to?
|
94
94
|
return count_nodes if count_nodes.present?
|
95
95
|
|
96
96
|
match_nodes = attribute_names.reduce(nil) do |chain, attribute_name|
|
@@ -104,6 +104,23 @@ module Pursuit
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def build_arel_for_reflection_join(reflection)
|
107
|
+
if reflection.belongs_to?
|
108
|
+
build_arel_for_belongs_to_reflection_join(reflection)
|
109
|
+
else
|
110
|
+
build_arel_for_has_reflection_join(reflection)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def build_arel_for_belongs_to_reflection_join(reflection)
|
115
|
+
reflection_table = reflection.klass.arel_table
|
116
|
+
reflection_table.where(
|
117
|
+
reflection_table[reflection.join_primary_key].eq(
|
118
|
+
options.record_class.arel_table[reflection.join_foreign_key]
|
119
|
+
)
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
def build_arel_for_has_reflection_join(reflection)
|
107
124
|
reflection_table = reflection.klass.arel_table
|
108
125
|
reflection_through = reflection.through_reflection
|
109
126
|
|
data/spec/pursuit/search_spec.rb
CHANGED
@@ -5,6 +5,7 @@ RSpec.describe Pursuit::Search do
|
|
5
5
|
|
6
6
|
let(:search_options) do
|
7
7
|
Pursuit::SearchOptions.new(Product) do |o|
|
8
|
+
o.relation :category, :name
|
8
9
|
o.relation :variations, :title, :stock_status
|
9
10
|
|
10
11
|
o.attribute :title
|
@@ -16,7 +17,7 @@ RSpec.describe Pursuit::Search do
|
|
16
17
|
])
|
17
18
|
end
|
18
19
|
|
19
|
-
o.attribute :
|
20
|
+
o.attribute :cat, :category_id
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -253,83 +254,20 @@ RSpec.describe Pursuit::Search do
|
|
253
254
|
end
|
254
255
|
end
|
255
256
|
|
256
|
-
context 'when
|
257
|
-
let(:query) { '
|
258
|
-
|
259
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
260
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
261
|
-
|
262
|
-
let(:product_variation_a) { ProductVariation.create!(product: product_a, title: 'Red') }
|
263
|
-
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
264
|
-
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
265
|
-
|
266
|
-
before do
|
267
|
-
product_a
|
268
|
-
product_b
|
269
|
-
|
270
|
-
product_variation_a
|
271
|
-
product_variation_b
|
272
|
-
product_variation_c
|
273
|
-
end
|
274
|
-
|
275
|
-
it 'is expected to contain the matching records' do
|
276
|
-
expect(perform).to contain_exactly(product_b)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
context 'when passed an `equal to` relationship count query' do
|
281
|
-
let(:query) { 'variations==1' }
|
282
|
-
|
283
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
284
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
285
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
286
|
-
|
287
|
-
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
288
|
-
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
289
|
-
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
290
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
291
|
-
|
292
|
-
before do
|
293
|
-
product_a
|
294
|
-
product_b
|
295
|
-
product_c
|
296
|
-
|
297
|
-
product_variation_a
|
298
|
-
product_variation_b
|
299
|
-
product_variation_c
|
300
|
-
product_variation_d
|
301
|
-
end
|
302
|
-
|
303
|
-
it 'is expected to contain the matching records' do
|
304
|
-
expect(perform).to contain_exactly(product_c)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
context 'when passed a `greater than` relationship count query' do
|
309
|
-
let(:query) { 'variations>1' }
|
257
|
+
context 'when querying a custom attribute whose name matches a reflection' do
|
258
|
+
let(:query) { 'cat==shirts' }
|
310
259
|
|
311
|
-
let(:
|
312
|
-
let(:
|
313
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
260
|
+
let(:shirts_category) { ProductCategory.create!(id: 'shirts', name: 'The Shirt Collection') }
|
261
|
+
let(:socks_category) { ProductCategory.create!(id: 'socks', name: 'The Sock Collection') }
|
314
262
|
|
315
|
-
let(:
|
316
|
-
let(:
|
317
|
-
let(:
|
318
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
319
|
-
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
320
|
-
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
263
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt', category: shirts_category) }
|
264
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt', category: shirts_category) }
|
265
|
+
let(:product_c) { Product.create!(title: 'Socks - Pack of 4', category: socks_category) }
|
321
266
|
|
322
267
|
before do
|
323
268
|
product_a
|
324
269
|
product_b
|
325
270
|
product_c
|
326
|
-
|
327
|
-
product_variation_a
|
328
|
-
product_variation_b
|
329
|
-
product_variation_c
|
330
|
-
product_variation_d
|
331
|
-
product_variation_e
|
332
|
-
product_variation_f
|
333
271
|
end
|
334
272
|
|
335
273
|
it 'is expected to contain the matching records' do
|
@@ -337,152 +275,243 @@ RSpec.describe Pursuit::Search do
|
|
337
275
|
end
|
338
276
|
end
|
339
277
|
|
340
|
-
context 'when
|
341
|
-
|
342
|
-
|
343
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
344
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
345
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
346
|
-
|
347
|
-
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
348
|
-
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
349
|
-
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
350
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
351
|
-
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
352
|
-
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
278
|
+
context 'when searching a #has_many relationship' do
|
279
|
+
context 'when passed a `match` relationship search query' do
|
280
|
+
let(:query) { 'variations*=green' }
|
353
281
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
282
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
283
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
284
|
+
|
285
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_a, title: 'Red') }
|
286
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
287
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
288
|
+
|
289
|
+
before do
|
290
|
+
product_a
|
291
|
+
product_b
|
292
|
+
|
293
|
+
product_variation_a
|
294
|
+
product_variation_b
|
295
|
+
product_variation_c
|
296
|
+
end
|
358
297
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
product_variation_d
|
363
|
-
product_variation_e
|
364
|
-
product_variation_f
|
298
|
+
it 'is expected to contain the matching records' do
|
299
|
+
expect(perform).to contain_exactly(product_b)
|
300
|
+
end
|
365
301
|
end
|
366
302
|
|
367
|
-
|
368
|
-
|
303
|
+
context 'when passed an `equal to` relationship count query' do
|
304
|
+
let(:query) { 'variations==1' }
|
305
|
+
|
306
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
307
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
308
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
309
|
+
|
310
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
311
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
312
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
313
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
314
|
+
|
315
|
+
before do
|
316
|
+
product_a
|
317
|
+
product_b
|
318
|
+
product_c
|
319
|
+
|
320
|
+
product_variation_a
|
321
|
+
product_variation_b
|
322
|
+
product_variation_c
|
323
|
+
product_variation_d
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'is expected to contain the matching records' do
|
327
|
+
expect(perform).to contain_exactly(product_c)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context 'when passed a `greater than` relationship count query' do
|
332
|
+
let(:query) { 'variations>1' }
|
333
|
+
|
334
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
335
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
336
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
337
|
+
|
338
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
339
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
340
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
341
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
342
|
+
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
343
|
+
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
344
|
+
|
345
|
+
before do
|
346
|
+
product_a
|
347
|
+
product_b
|
348
|
+
product_c
|
349
|
+
|
350
|
+
product_variation_a
|
351
|
+
product_variation_b
|
352
|
+
product_variation_c
|
353
|
+
product_variation_d
|
354
|
+
product_variation_e
|
355
|
+
product_variation_f
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'is expected to contain the matching records' do
|
359
|
+
expect(perform).to contain_exactly(product_a, product_b)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
context 'when passed a `greater than or equal to` relationship count query' do
|
364
|
+
let(:query) { 'variations>=2' }
|
365
|
+
|
366
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
367
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
368
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
369
|
+
|
370
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
371
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
372
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
373
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
374
|
+
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
375
|
+
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
376
|
+
|
377
|
+
before do
|
378
|
+
product_a
|
379
|
+
product_b
|
380
|
+
product_c
|
381
|
+
|
382
|
+
product_variation_a
|
383
|
+
product_variation_b
|
384
|
+
product_variation_c
|
385
|
+
product_variation_d
|
386
|
+
product_variation_e
|
387
|
+
product_variation_f
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'is expected to contain the matching records' do
|
391
|
+
expect(perform).to contain_exactly(product_a, product_b)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
context 'when passed a `less than` relationship count query' do
|
396
|
+
let(:query) { 'variations<3' }
|
397
|
+
|
398
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
399
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
400
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
401
|
+
|
402
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
403
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
404
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
405
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
406
|
+
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
407
|
+
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
408
|
+
|
409
|
+
before do
|
410
|
+
product_a
|
411
|
+
product_b
|
412
|
+
product_c
|
413
|
+
|
414
|
+
product_variation_a
|
415
|
+
product_variation_b
|
416
|
+
product_variation_c
|
417
|
+
product_variation_d
|
418
|
+
product_variation_e
|
419
|
+
product_variation_f
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'is expected to contain the matching records' do
|
423
|
+
expect(perform).to contain_exactly(product_a, product_c)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
context 'when passed a `less than or equal to` relationship count query' do
|
428
|
+
let(:query) { 'variations<=2' }
|
429
|
+
|
430
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
431
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
432
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
433
|
+
|
434
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
435
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
436
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
437
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
438
|
+
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
439
|
+
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
440
|
+
|
441
|
+
before do
|
442
|
+
product_a
|
443
|
+
product_b
|
444
|
+
product_c
|
445
|
+
|
446
|
+
product_variation_a
|
447
|
+
product_variation_b
|
448
|
+
product_variation_c
|
449
|
+
product_variation_d
|
450
|
+
product_variation_e
|
451
|
+
product_variation_f
|
452
|
+
end
|
453
|
+
|
454
|
+
it 'is expected to contain the matching records' do
|
455
|
+
expect(perform).to contain_exactly(product_a, product_c)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
context 'when passed a `greater than` and `less than` relationship count query' do
|
460
|
+
let(:query) { 'variations>1 variations<3' }
|
461
|
+
|
462
|
+
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
463
|
+
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
464
|
+
let(:product_c) { Product.create!(title: 'Socks') }
|
465
|
+
|
466
|
+
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
467
|
+
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
468
|
+
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
469
|
+
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
470
|
+
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
471
|
+
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
472
|
+
|
473
|
+
before do
|
474
|
+
product_a
|
475
|
+
product_b
|
476
|
+
product_c
|
477
|
+
|
478
|
+
product_variation_a
|
479
|
+
product_variation_b
|
480
|
+
product_variation_c
|
481
|
+
product_variation_d
|
482
|
+
product_variation_e
|
483
|
+
product_variation_f
|
484
|
+
end
|
485
|
+
|
486
|
+
it 'is expected to contain the matching records' do
|
487
|
+
expect(perform).to contain_exactly(product_a)
|
488
|
+
end
|
369
489
|
end
|
370
490
|
end
|
371
491
|
|
372
|
-
context 'when
|
373
|
-
|
492
|
+
context 'when searching a #belongs_to relationship' do
|
493
|
+
context 'when passed a `match` relationship search query' do
|
494
|
+
let(:query) { 'category*=shirt' }
|
374
495
|
|
375
|
-
|
376
|
-
|
377
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
496
|
+
let(:product_category_a) { ProductCategory.create!(id: 'one', name: 'Shirts') }
|
497
|
+
let(:product_category_b) { ProductCategory.create!(id: 'two', name: 'Socks') }
|
378
498
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
383
|
-
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
384
|
-
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
499
|
+
let(:product_a) { Product.create!(category: product_category_a, title: 'Plain Shirt') }
|
500
|
+
let(:product_b) { Product.create!(category: product_category_a, title: 'Funky Shirt') }
|
501
|
+
let(:product_c) { Product.create!(category: product_category_b, title: 'White Socks') }
|
385
502
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
product_c
|
390
|
-
|
391
|
-
product_variation_a
|
392
|
-
product_variation_b
|
393
|
-
product_variation_c
|
394
|
-
product_variation_d
|
395
|
-
product_variation_e
|
396
|
-
product_variation_f
|
397
|
-
end
|
398
|
-
|
399
|
-
it 'is expected to contain the matching records' do
|
400
|
-
expect(perform).to contain_exactly(product_a, product_c)
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
context 'when passed a `less than or equal to` relationship count query' do
|
405
|
-
let(:query) { 'variations<=2' }
|
406
|
-
|
407
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
408
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
409
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
410
|
-
|
411
|
-
let(:product_variation_a) { ProductVariation.create!(product: product_b, title: 'Red') }
|
412
|
-
let(:product_variation_b) { ProductVariation.create!(product: product_b, title: 'Green') }
|
413
|
-
let(:product_variation_c) { ProductVariation.create!(product: product_b, title: 'Blue') }
|
414
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
415
|
-
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
416
|
-
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
417
|
-
|
418
|
-
before do
|
419
|
-
product_a
|
420
|
-
product_b
|
421
|
-
product_c
|
503
|
+
before do
|
504
|
+
product_category_a
|
505
|
+
product_category_b
|
422
506
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
product_variation_e
|
428
|
-
product_variation_f
|
429
|
-
end
|
430
|
-
|
431
|
-
it 'is expected to contain the matching records' do
|
432
|
-
expect(perform).to contain_exactly(product_a, product_c)
|
433
|
-
end
|
434
|
-
end
|
435
|
-
|
436
|
-
context 'when passed a `greater than` and `less than` relationship count query' do
|
437
|
-
let(:query) { 'variations>1 variations<3' }
|
438
|
-
|
439
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt') }
|
440
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt') }
|
441
|
-
let(:product_c) { Product.create!(title: 'Socks') }
|
507
|
+
product_a
|
508
|
+
product_b
|
509
|
+
product_c
|
510
|
+
end
|
442
511
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
let(:product_variation_d) { ProductVariation.create!(product: product_c, title: 'White') }
|
447
|
-
let(:product_variation_e) { ProductVariation.create!(product: product_a, title: 'Black') }
|
448
|
-
let(:product_variation_f) { ProductVariation.create!(product: product_a, title: 'Gray') }
|
449
|
-
|
450
|
-
before do
|
451
|
-
product_a
|
452
|
-
product_b
|
453
|
-
product_c
|
454
|
-
|
455
|
-
product_variation_a
|
456
|
-
product_variation_b
|
457
|
-
product_variation_c
|
458
|
-
product_variation_d
|
459
|
-
product_variation_e
|
460
|
-
product_variation_f
|
461
|
-
end
|
462
|
-
|
463
|
-
it 'is expected to contain the matching records' do
|
464
|
-
expect(perform).to contain_exactly(product_a)
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
context 'when querying a custom attribute whose name matches a reflection' do
|
469
|
-
let(:query) { 'category==shirts' }
|
470
|
-
|
471
|
-
let(:shirts_category) { ProductCategory.create!(id: 'shirts', name: 'The Shirt Collection') }
|
472
|
-
let(:socks_category) { ProductCategory.create!(id: 'socks', name: 'The Sock Collection') }
|
473
|
-
|
474
|
-
let(:product_a) { Product.create!(title: 'Plain Shirt', category: shirts_category) }
|
475
|
-
let(:product_b) { Product.create!(title: 'Funky Shirt', category: shirts_category) }
|
476
|
-
let(:product_c) { Product.create!(title: 'Socks - Pack of 4', category: socks_category) }
|
477
|
-
|
478
|
-
before do
|
479
|
-
product_a
|
480
|
-
product_b
|
481
|
-
product_c
|
482
|
-
end
|
483
|
-
|
484
|
-
it 'is expected to contain the matching records' do
|
485
|
-
expect(perform).to contain_exactly(product_a, product_b)
|
512
|
+
it 'is expected to contain the matching records' do
|
513
|
+
expect(perform).to contain_exactly(product_a, product_b)
|
514
|
+
end
|
486
515
|
end
|
487
516
|
end
|
488
517
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pursuit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nialto Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|