spree_api 3.3.2 → 3.3.3

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
  SHA1:
3
- metadata.gz: 2a2b77c91dc840ee5dee729a0f07dba260c9899e
4
- data.tar.gz: 13a8dd4ccf207a13d75e8debec9832fd98b39fc1
3
+ metadata.gz: 6915e8f0e8af6dc55d88e85a9c3a0211fe6bfbfa
4
+ data.tar.gz: 3928d9716a7dc2f3c62fe7a9f77e9e4647649ebc
5
5
  SHA512:
6
- metadata.gz: 8fe165c07b0a8f767c5c57fbf93bc0ef518ac146d1da84d62be34234b86d89e52b500e8e6e75f18f48c4ebddd8ecb1912227b8eb21d90de8b88f20e6158676e1
7
- data.tar.gz: 40d9a5298c2e9c6d9ae73070106919107b546e4dc1415509e03473a3e33d97da667f6212dde7878607a85930bca834a8573ac73c168b16f8b556eaebb3327973
6
+ metadata.gz: cdf0580320b0432d991c35ae8c94ba6401d518e63e3f775a99cf7f4df59f57add00160ceb9bdf7550ec406b5ac491c2f3d1d8e022c5e9957cfe6d354af1fb0ab
7
+ data.tar.gz: 3b59ed63cbf9b2beee4ff47d856be8d1a2ac4a5a69aba39b43f30c8bb554488e77fa453a15e52e6504032df1662b2f35abb990a2031d399a136f9b17bfa3285c
@@ -27,8 +27,6 @@ module Spree
27
27
  @shipment = @order.shipments.create(stock_location_id: params.fetch(:stock_location_id))
28
28
  @order.contents.add(variant, quantity, {shipment: @shipment})
29
29
 
30
- @shipment.save!
31
-
32
30
  respond_with(@shipment.reload, default_template: :show)
33
31
  end
34
32
 
@@ -60,16 +58,24 @@ module Spree
60
58
  def add
61
59
  quantity = params[:quantity].to_i
62
60
 
63
- @shipment.order.contents.add(variant, quantity, {shipment: @shipment})
64
-
61
+ @shipment.order.contents.add(variant, quantity, shipment: @shipment)
65
62
  respond_with(@shipment, default_template: :show)
66
63
  end
67
64
 
68
65
  def remove
69
- quantity = params[:quantity].to_i
66
+ quantity = if params.key?(:quantity)
67
+ params[:quantity].to_i
68
+ else
69
+ @shipment.inventory_units_for(variant).sum(:quantity)
70
+ end
71
+ @shipment.order.contents.remove(variant, quantity, shipment: @shipment)
72
+
73
+ if @shipment.inventory_units.any?
74
+ @shipment.reload
75
+ else
76
+ @shipment.destroy!
77
+ end
70
78
 
71
- @shipment.order.contents.remove(variant, quantity, {shipment: @shipment})
72
- @shipment.reload if @shipment.persisted?
73
79
  respond_with(@shipment, default_template: :show)
74
80
  end
75
81
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2017-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.2
19
+ version: 3.3.3
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.3.2
26
+ version: 3.3.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement