workarea-product_bundles 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64b07c1db1ca79214a181bb235cbc7727cca8ba27a5e749154b6eca61acd3469
4
- data.tar.gz: 0aa7cdcf01df76f2e68c8dc6e09fb623ea51b177203d4ccf6a64ea17612c5421
3
+ metadata.gz: 2aa863019af1e17c7539be46f8df7eab303deb18f2766516f72eb26c024a8c18
4
+ data.tar.gz: b398c8e65fcbf5d79edd86004231f1f6a44324458abe9f18206d5508f853f9c9
5
5
  SHA512:
6
- metadata.gz: 47617b62ad511652cb9984c5937fefdc0cf2f860afa9cca182624bf801d5bca4cb0e8f46637008db1b564eb5ce2e345db6d263f0f5a29240a7fbcf82ce6dee3e
7
- data.tar.gz: ca90577659eb1fdeca445d1381aa2ab9b70f01c988b24196e2450a124e8f3cc6ef091ba64aa70b96fff610f38dcb33213458308d2775cd61637e2026ce975efd
6
+ metadata.gz: ab6169abf06ca83e51583766413278d135ffdfa0ba607b1261d27b989049f8d0a3ec8657ebca73781f3a08e98d46b75a601807c633d11642635a63df1d632921
7
+ data.tar.gz: 1525515328382b5cddd22ff507a92c508ab5510935c99af2441beff97f7b46407790268bb267f8c34dc8b970bf94220539615f61ff1e687aa1fa43ba9a9b2c06
@@ -1,3 +1,30 @@
1
+ Workarea Product Bundles 1.0.1 (2020-11-13)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Fix Error on Missing Components Params
5
+
6
+ The `:components` param sent into `BuildKitVariants` can point to empty
7
+ hashes. If this is the case, ensure that `#component_groups` does not
8
+ throw an error, but rather returns an empty Array so downstream
9
+ consumers can handle the situation gracefully.
10
+
11
+ BUNDLES-25
12
+
13
+ Tom Scott
14
+
15
+ * Add Sample Images To Seeds
16
+
17
+ Using the logic in `Workarea::ProductsSeeds`, apply random images from
18
+ the sample images cache to the products in `ProductBundleSeeds`. This
19
+ makes product bundles look like any other product when seeding the
20
+ database.
21
+
22
+ BUNDLES-24
23
+
24
+ Tom Scott
25
+
26
+
27
+
1
28
  Workarea Product Bundles 1.0.0 (2020-10-14)
2
29
  --------------------------------------------------------------------------------
3
30
 
@@ -1,5 +1,11 @@
1
1
  module Workarea
2
2
  class ProductBundleSeeds
3
+ delegate :find_random_image, to: :@products_seeds
4
+
5
+ def initialize
6
+ @products_seeds = ProductsSeeds.new
7
+ end
8
+
3
9
  def perform
4
10
  puts 'Adding product bundles...'
5
11
 
@@ -54,6 +60,10 @@ module Workarea
54
60
  end
55
61
  end
56
62
 
63
+ if (sample_image = find_random_image).present?
64
+ product.images.create!(image: sample_image)
65
+ end
66
+
57
67
  product
58
68
  end
59
69
  end
@@ -38,6 +38,7 @@ module Workarea
38
38
  def component_groups
39
39
  return @component_groups if defined?(@component_groups)
40
40
  pieces = params.components
41
+ return [] unless pieces.present?
41
42
  @component_groups = pieces.shift.product(*pieces)
42
43
  end
43
44
 
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module ProductBundles
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  end
@@ -263,5 +263,21 @@ module Workarea
263
263
  refute(summary.duplicate_details?)
264
264
  assert(summary.invalid_details?)
265
265
  end
266
+
267
+ def test_component_groups
268
+ kit = create_product(
269
+ name: 'Test Kit',
270
+ variants: [],
271
+ product_ids: %w(PROD1 PROD2)
272
+ )
273
+ build = BuildKitVariants.new(kit, params)
274
+
275
+ refute_empty(build.component_groups)
276
+ assert_kind_of(Hash, build.component_groups.first.first)
277
+
278
+ build = BuildKitVariants.new(kit, params.merge(components: { '1' => {} }))
279
+
280
+ assert_empty(build.component_groups)
281
+ end
266
282
  end
267
283
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-product_bundles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Duffy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea