spree_api 3.4.1 → 3.4.2

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: 6ebd59d99d0462bbbc714214d46324a2584b7e37
4
- data.tar.gz: 493bb3db874f46a7cc00c220e585deded72ac329
3
+ metadata.gz: 8b03a74b1a9c26442b47bd4cafc751ab4aca8b57
4
+ data.tar.gz: ff3854cca3d4e175eef15ebce69f55f8d253e358
5
5
  SHA512:
6
- metadata.gz: 888dcc8814a565e2a953aa770d6dd9cc79675080dbdf765c9aaf39e2b42bd36d852f38f8b9462a7955060aa751ace64852c149a6f869aba56a5f3262152b65aa
7
- data.tar.gz: 2684c931bd3392aa451bd2de70b15664b10b087b8578876d0bbbfa554d14bfc0c05153f7c1c6865122bc52b79eea9c0acc43794a9113b09046347d15a1c3ce7e
6
+ metadata.gz: c7e16209da056ce552fd01451ef01d708162cf9588769b86d860a43fd6819cc5445cc9ef43e3a9c27a0e571e58fc1fa4927211a75e3e1b72aa842c8585469ec2
7
+ data.tar.gz: 0dca3e352a84ca5ecb6ffd14b8466de305dff8c38f3201c53b0b1efd4f8a6b62b39c52c7a7dce05191dd8ca99b5771fddded75a11044970721c23213e80b43ac
@@ -26,8 +26,6 @@ module Spree
26
26
  @shipment = @order.shipments.create(stock_location_id: params.fetch(:stock_location_id))
27
27
  @order.contents.add(variant, quantity, shipment: @shipment)
28
28
 
29
- @shipment.save!
30
-
31
29
  respond_with(@shipment.reload, default_template: :show)
32
30
  end
33
31
 
@@ -58,15 +56,23 @@ module Spree
58
56
  quantity = params[:quantity].to_i
59
57
 
60
58
  @shipment.order.contents.add(variant, quantity, shipment: @shipment)
61
-
62
59
  respond_with(@shipment, default_template: :show)
63
60
  end
64
61
 
65
62
  def remove
66
- quantity = params[:quantity].to_i
67
-
63
+ quantity = if params.key?(:quantity)
64
+ params[:quantity].to_i
65
+ else
66
+ @shipment.inventory_units_for(variant).sum(:quantity)
67
+ end
68
68
  @shipment.order.contents.remove(variant, quantity, shipment: @shipment)
69
- @shipment.reload if @shipment.persisted?
69
+
70
+ if @shipment.inventory_units.any?
71
+ @shipment.reload
72
+ else
73
+ @shipment.destroy!
74
+ end
75
+
70
76
  respond_with(@shipment, default_template: :show)
71
77
  end
72
78
 
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.4.1
4
+ version: 3.4.2
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-10-20 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.4.1
19
+ version: 3.4.2
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.1
26
+ version: 3.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement