workarea-storefront 3.4.43 → 3.4.44

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: 939c36b4b4c5c3f9b0d4af10ece9633ed5557397d555a36ea396d662fbbbef29
4
- data.tar.gz: f48a875a8c70aa31d4d8efccf3353f74770f4ea3128b7b451c8d3b238d6e414d
3
+ metadata.gz: c8ec81c2c84abe158b4b85c9cfd61d0b1ac1744204335ce13f359e10545292f6
4
+ data.tar.gz: a08eccfd85655d324faf8c7bfb4fe45c5a169eb55ceff18acdb7a19ded03cbaf
5
5
  SHA512:
6
- metadata.gz: 2caabdec4b487a15243b53d39f1d641b6bf5ece9878324237c364e29483e10567b1d32bf901077dd8c567e0ff34eb1d377d6d78a28727c80ab9acbe0a9f124b1
7
- data.tar.gz: 2482f324b517bead01554ed1ae7d009d0b19153c369eaf4d9f5823eebfe3e52dcd004465176172886935af198b20ffcb97620bea1c3d1f77b9a3a936154af5e7
6
+ metadata.gz: a06ba63b1c9bd36648745fd24bfcaef9a1a01ebe380328f171bede3248e83b197ff97a5628fb1ea386ddb3853bb6590e16b0097b935c7a1b9091f7601fcde335
7
+ data.tar.gz: 80bf09f01d4b261b884647d8bf7ca8b7db40b6335399dab52b7a823d4c5c1604ab17bd8389bfadb7619e89b2a87da09db13b43005949e91813cd86a3c72fea75
@@ -11,13 +11,14 @@ module Workarea
11
11
  after_action :check_inventory, except: :create
12
12
 
13
13
  def create
14
+ @cart = CartViewModel.new(current_order, view_model_options)
15
+
14
16
  # TODO: for v4, use AddItemToCart for this.
15
17
  if current_order.add_item(item_params.to_h.merge(item_details.to_h))
16
18
  check_inventory
17
19
 
18
20
  Pricing.perform(current_order, current_shippings)
19
21
 
20
- @cart = CartViewModel.new(current_order, view_model_options)
21
22
  @item = OrderItemViewModel.wrap(
22
23
  current_order.items.find_existing(
23
24
  item_params[:sku],
@@ -1,7 +1,6 @@
1
1
  module Workarea
2
2
  module Storefront
3
3
  class ProductViewModel < ApplicationViewModel
4
-
5
4
  def self.wrap(model, options = {})
6
5
  if model.is_a?(Enumerable)
7
6
  model.map { |m| wrap(m, options) }
@@ -11,6 +10,8 @@ module Workarea
11
10
  else
12
11
  new(model, options)
13
12
  end
13
+ rescue NameError
14
+ new(model, options)
14
15
  end
15
16
 
16
17
  def breadcrumbs
@@ -47,6 +47,18 @@ module Workarea
47
47
  assert_equal(5.to_m, order.items.first.total_price)
48
48
  end
49
49
 
50
+ def test_fail_to_add_an_item
51
+ post storefront.cart_items_path,
52
+ params: {
53
+ product_id: @product.id,
54
+ sku: 'SKU1',
55
+ quantity: -1
56
+ }
57
+
58
+ assert_response(:success)
59
+ assert_empty(Order.all)
60
+ end
61
+
50
62
  def test_adding_product_with_shared_skus
51
63
  product_2 = Catalog::Product.create!(name: 'Product', variants: [{ sku: 'SKU1' }])
52
64
 
@@ -15,6 +15,14 @@ module Workarea
15
15
  view_model = ProductViewModel.wrap(@product, one: '1')
16
16
  assert_instance_of(ProductTemplates::OptionSelectsViewModel, view_model)
17
17
  assert_equal('1', view_model.options[:one])
18
+
19
+ Workarea.with_config do |config|
20
+ config.product_templates << :no_view_model
21
+ @product.template = 'no_view_model'
22
+ view_model = ProductViewModel.wrap(@product, one: '1')
23
+
24
+ assert_kind_of(ProductViewModel, view_model)
25
+ end
18
26
  end
19
27
 
20
28
  def test_cache_key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-storefront
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.43
4
+ version: 3.4.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.43
19
+ version: 3.4.44
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.4.43
26
+ version: 3.4.44
27
27
  description: Provides user-facing ecommerce storefront functionality for the Workarea
28
28
  Commerce Platform.
29
29
  email: