solidus_api 2.4.2 → 2.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_api might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +1 -5
- data/Rakefile +7 -8
- data/app/controllers/spree/api/line_items_controller.rb +1 -3
- data/app/controllers/spree/api/orders_controller.rb +1 -1
- data/app/controllers/spree/api/products_controller.rb +1 -1
- data/app/controllers/spree/api/shipments_controller.rb +21 -7
- data/app/controllers/spree/api/stock_items_controller.rb +4 -4
- data/app/controllers/spree/api/taxonomies_controller.rb +1 -0
- data/app/controllers/spree/api/taxons_controller.rb +1 -0
- data/app/controllers/spree/api/variants_controller.rb +13 -4
- data/app/helpers/spree/api/api_helpers.rb +0 -9
- data/app/views/spree/api/shared/_pagination.json.jbuilder +1 -1
- data/app/views/spree/api/shipments/estimated_rates.json.jbuilder +4 -0
- data/app/views/spree/api/variants/_big.json.jbuilder +0 -1
- data/app/views/spree/api/variants/_small.json.jbuilder +6 -1
- data/config/locales/en.yml +0 -6
- data/config/routes.rb +3 -7
- data/lib/spree/api/engine.rb +0 -10
- data/lib/spree_api.rb +0 -1
- data/solidus_api.gemspec +1 -2
- data/spec/controllers/spree/api/resource_controller_spec.rb +9 -9
- data/spec/features/checkout_spec.rb +8 -8
- data/spec/requests/api/address_books_spec.rb +1 -3
- data/spec/requests/spree/api/checkouts_controller_spec.rb +4 -5
- data/spec/requests/spree/api/config_controller_spec.rb +2 -2
- data/spec/requests/spree/api/orders_controller_spec.rb +27 -11
- data/spec/requests/spree/api/products_controller_spec.rb +1 -1
- data/spec/requests/spree/api/return_authorizations_controller_spec.rb +13 -13
- data/spec/requests/spree/api/shipments_controller_spec.rb +66 -4
- data/spec/requests/spree/api/stock_items_controller_spec.rb +4 -4
- data/spec/requests/spree/api/stock_locations_controller_spec.rb +7 -7
- data/spec/requests/spree/api/taxonomies_controller_spec.rb +1 -0
- data/spec/requests/spree/api/taxons_controller_spec.rb +3 -2
- data/spec/requests/spree/api/variants_controller_spec.rb +26 -0
- data/spec/spec_helper.rb +13 -23
- metadata +11 -41
- data/Gemfile +0 -5
- data/app/controllers/spree/api/stock_transfers_controller.rb +0 -20
- data/app/controllers/spree/api/transfer_items_controller.rb +0 -42
- data/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder +0 -1
- data/app/views/spree/api/stock_transfers/receive.json.jbuilder +0 -4
- data/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder +0 -5
- data/app/views/spree/api/transfer_items/show.json.jbuilder +0 -1
- data/spec/requests/spree/api/stock_transfers_controller_spec.rb +0 -97
- data/spec/requests/spree/api/transfer_items_controller_spec.rb +0 -150
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.5.0.beta1
|
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: 2.
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: versioncake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.0'
|
26
|
+
version: 2.5.0.beta1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: responders
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,25 +53,19 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '2.6'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: kaminari
|
56
|
+
name: kaminari-activerecord
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.17'
|
76
|
-
- - "<"
|
59
|
+
- - "~>"
|
77
60
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
61
|
+
version: '1.1'
|
79
62
|
type: :runtime
|
80
63
|
prerelease: false
|
81
64
|
version_requirements: !ruby/object:Gem::Requirement
|
82
65
|
requirements:
|
83
|
-
- - "
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0.17'
|
86
|
-
- - "<"
|
66
|
+
- - "~>"
|
87
67
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
68
|
+
version: '1.1'
|
89
69
|
description: REST API for the Solidus e-commerce framework.
|
90
70
|
email: contact@solidus.io
|
91
71
|
executables: []
|
@@ -93,7 +73,6 @@ extensions: []
|
|
93
73
|
extra_rdoc_files: []
|
94
74
|
files:
|
95
75
|
- ".gitignore"
|
96
|
-
- Gemfile
|
97
76
|
- LICENSE
|
98
77
|
- README.md
|
99
78
|
- Rakefile
|
@@ -123,12 +102,10 @@ files:
|
|
123
102
|
- app/controllers/spree/api/stock_items_controller.rb
|
124
103
|
- app/controllers/spree/api/stock_locations_controller.rb
|
125
104
|
- app/controllers/spree/api/stock_movements_controller.rb
|
126
|
-
- app/controllers/spree/api/stock_transfers_controller.rb
|
127
105
|
- app/controllers/spree/api/store_credit_events_controller.rb
|
128
106
|
- app/controllers/spree/api/stores_controller.rb
|
129
107
|
- app/controllers/spree/api/taxonomies_controller.rb
|
130
108
|
- app/controllers/spree/api/taxons_controller.rb
|
131
|
-
- app/controllers/spree/api/transfer_items_controller.rb
|
132
109
|
- app/controllers/spree/api/users_controller.rb
|
133
110
|
- app/controllers/spree/api/variants_controller.rb
|
134
111
|
- app/controllers/spree/api/zones_controller.rb
|
@@ -153,7 +130,6 @@ files:
|
|
153
130
|
- app/views/spree/api/errors/must_specify_api_key.json.jbuilder
|
154
131
|
- app/views/spree/api/errors/not_found.json.jbuilder
|
155
132
|
- app/views/spree/api/errors/unauthorized.json.jbuilder
|
156
|
-
- app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder
|
157
133
|
- app/views/spree/api/images/_image.json.jbuilder
|
158
134
|
- app/views/spree/api/images/index.json.jbuilder
|
159
135
|
- app/views/spree/api/images/show.json.jbuilder
|
@@ -200,6 +176,7 @@ files:
|
|
200
176
|
- app/views/spree/api/shipments/_big.json.jbuilder
|
201
177
|
- app/views/spree/api/shipments/_small.json.jbuilder
|
202
178
|
- app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder
|
179
|
+
- app/views/spree/api/shipments/estimated_rates.json.jbuilder
|
203
180
|
- app/views/spree/api/shipments/mine.json.jbuilder
|
204
181
|
- app/views/spree/api/shipments/show.json.jbuilder
|
205
182
|
- app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder
|
@@ -214,7 +191,6 @@ files:
|
|
214
191
|
- app/views/spree/api/stock_movements/_stock_movement.json.jbuilder
|
215
192
|
- app/views/spree/api/stock_movements/index.json.jbuilder
|
216
193
|
- app/views/spree/api/stock_movements/show.json.jbuilder
|
217
|
-
- app/views/spree/api/stock_transfers/receive.json.jbuilder
|
218
194
|
- app/views/spree/api/store_credit_events/mine.json.jbuilder
|
219
195
|
- app/views/spree/api/stores/index.json.jbuilder
|
220
196
|
- app/views/spree/api/stores/show.json.jbuilder
|
@@ -230,8 +206,6 @@ files:
|
|
230
206
|
- app/views/spree/api/taxons/jstree.json.jbuilder
|
231
207
|
- app/views/spree/api/taxons/new.json.jbuilder
|
232
208
|
- app/views/spree/api/taxons/show.json.jbuilder
|
233
|
-
- app/views/spree/api/transfer_items/_transfer_item.json.jbuilder
|
234
|
-
- app/views/spree/api/transfer_items/show.json.jbuilder
|
235
209
|
- app/views/spree/api/users/_user.json.jbuilder
|
236
210
|
- app/views/spree/api/users/index.json.jbuilder
|
237
211
|
- app/views/spree/api/users/new.json.jbuilder
|
@@ -293,12 +267,10 @@ files:
|
|
293
267
|
- spec/requests/spree/api/stock_items_controller_spec.rb
|
294
268
|
- spec/requests/spree/api/stock_locations_controller_spec.rb
|
295
269
|
- spec/requests/spree/api/stock_movements_controller_spec.rb
|
296
|
-
- spec/requests/spree/api/stock_transfers_controller_spec.rb
|
297
270
|
- spec/requests/spree/api/store_credit_events_controller_spec.rb
|
298
271
|
- spec/requests/spree/api/stores_controller_spec.rb
|
299
272
|
- spec/requests/spree/api/taxonomies_controller_spec.rb
|
300
273
|
- spec/requests/spree/api/taxons_controller_spec.rb
|
301
|
-
- spec/requests/spree/api/transfer_items_controller_spec.rb
|
302
274
|
- spec/requests/spree/api/unauthenticated_products_controller_spec.rb
|
303
275
|
- spec/requests/spree/api/users_controller_spec.rb
|
304
276
|
- spec/requests/spree/api/variants_controller_spec.rb
|
@@ -333,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
333
305
|
version: 1.8.23
|
334
306
|
requirements: []
|
335
307
|
rubyforge_project:
|
336
|
-
rubygems_version: 2.
|
308
|
+
rubygems_version: 2.7.3
|
337
309
|
signing_key:
|
338
310
|
specification_version: 4
|
339
311
|
summary: REST API for the Solidus e-commerce framework.
|
@@ -370,12 +342,10 @@ test_files:
|
|
370
342
|
- spec/requests/spree/api/stock_items_controller_spec.rb
|
371
343
|
- spec/requests/spree/api/stock_locations_controller_spec.rb
|
372
344
|
- spec/requests/spree/api/stock_movements_controller_spec.rb
|
373
|
-
- spec/requests/spree/api/stock_transfers_controller_spec.rb
|
374
345
|
- spec/requests/spree/api/store_credit_events_controller_spec.rb
|
375
346
|
- spec/requests/spree/api/stores_controller_spec.rb
|
376
347
|
- spec/requests/spree/api/taxonomies_controller_spec.rb
|
377
348
|
- spec/requests/spree/api/taxons_controller_spec.rb
|
378
|
-
- spec/requests/spree/api/transfer_items_controller_spec.rb
|
379
349
|
- spec/requests/spree/api/unauthenticated_products_controller_spec.rb
|
380
350
|
- spec/requests/spree/api/users_controller_spec.rb
|
381
351
|
- spec/requests/spree/api/variants_controller_spec.rb
|
data/Gemfile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
class StockTransfersController < Spree::Api::BaseController
|
4
|
-
def receive
|
5
|
-
authorize! :update, TransferItem
|
6
|
-
@stock_transfer = Spree::StockTransfer.accessible_by(current_ability, :update).find_by!(number: params[:id])
|
7
|
-
variant = Spree::Variant.accessible_by(current_ability, :show).find(params[:variant_id])
|
8
|
-
@transfer_item = @stock_transfer.transfer_items.find_by(variant: variant)
|
9
|
-
if @transfer_item.nil?
|
10
|
-
logger.error("variant_not_in_stock_transfer")
|
11
|
-
render "spree/api/errors/variant_not_in_stock_transfer", status: 422
|
12
|
-
elsif @transfer_item.update_attributes(received_quantity: @transfer_item.received_quantity + 1)
|
13
|
-
render 'spree/api/stock_transfers/receive', status: 200
|
14
|
-
else
|
15
|
-
invalid_resource!(@transfer_item)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Api
|
3
|
-
class TransferItemsController < Spree::Api::BaseController
|
4
|
-
def create
|
5
|
-
authorize! :create, TransferItem
|
6
|
-
stock_transfer = Spree::StockTransfer.accessible_by(current_ability, :update).find_by(number: params[:stock_transfer_id])
|
7
|
-
@transfer_item = stock_transfer.transfer_items.build(transfer_item_params)
|
8
|
-
if @transfer_item.save
|
9
|
-
respond_with(@transfer_item, status: 201, default_template: :show)
|
10
|
-
else
|
11
|
-
invalid_resource!(@transfer_item)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def update
|
16
|
-
authorize! :update, TransferItem
|
17
|
-
@transfer_item = Spree::TransferItem.accessible_by(current_ability, :update).find(params[:id])
|
18
|
-
if @transfer_item.update_attributes(transfer_item_params)
|
19
|
-
respond_with(@transfer_item, status: 200, default_template: :show)
|
20
|
-
else
|
21
|
-
invalid_resource!(@transfer_item)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def destroy
|
26
|
-
authorize! :destroy, TransferItem
|
27
|
-
@transfer_item = Spree::TransferItem.accessible_by(current_ability, :destroy).find(params[:id])
|
28
|
-
if @transfer_item.destroy
|
29
|
-
respond_with(@transfer_item, status: 200, default_template: :show)
|
30
|
-
else
|
31
|
-
invalid_resource!(@transfer_item)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def transfer_item_params
|
38
|
-
params.require(:transfer_item).permit(permitted_transfer_item_attributes)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
json.error(Spree.t(:item_not_in_stock_transfer))
|
@@ -1 +0,0 @@
|
|
1
|
-
json.partial!("spree/api/transfer_items/transfer_item", transfer_item: @transfer_item)
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
describe Api::StockTransfersController do
|
5
|
-
|
6
|
-
let!(:stock_transfer) { create(:stock_transfer_with_items) }
|
7
|
-
let(:transfer_item) { stock_transfer.transfer_items.first }
|
8
|
-
|
9
|
-
before do
|
10
|
-
stub_authentication!
|
11
|
-
end
|
12
|
-
|
13
|
-
context "as a normal user" do
|
14
|
-
describe "#receive" do
|
15
|
-
it "cannot receive transfer items from a stock transfer" do
|
16
|
-
post spree.receive_api_stock_transfer_path(stock_transfer), params: { variant_id: transfer_item.variant }
|
17
|
-
expect(response.status).to eq 401
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "as an admin" do
|
23
|
-
sign_in_as_admin!
|
24
|
-
|
25
|
-
describe "#receive" do
|
26
|
-
subject do
|
27
|
-
post spree.receive_api_stock_transfer_path(stock_transfer), params: { variant_id: variant_id }
|
28
|
-
end
|
29
|
-
|
30
|
-
context "valid parameters" do
|
31
|
-
let(:variant_id) { transfer_item.variant.to_param }
|
32
|
-
|
33
|
-
it "can receive a transfer items from a stock transfer" do
|
34
|
-
subject
|
35
|
-
expect(response.status).to eq 200
|
36
|
-
end
|
37
|
-
|
38
|
-
it "increments the received quantity for the transfer_item" do
|
39
|
-
expect { subject }.to change { transfer_item.reload.received_quantity }.by(1)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns the received transfer item in the response" do
|
43
|
-
subject
|
44
|
-
expect(JSON.parse(response.body)["received_item"]["id"]).to eq transfer_item.id
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "transfer item does not have stock in source location after ship" do
|
49
|
-
let(:variant_id) { transfer_item.variant.to_param }
|
50
|
-
let(:user) { create :user }
|
51
|
-
|
52
|
-
before do
|
53
|
-
stock_transfer.finalize(user)
|
54
|
-
stock_transfer.ship(shipped_at: Time.current)
|
55
|
-
stock_transfer.source_location.stock_item(transfer_item.variant_id).set_count_on_hand(0)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can still receive item" do
|
59
|
-
expect { subject }.to change { transfer_item.reload.received_quantity }.by(1)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "transfer item has been fully received" do
|
64
|
-
let(:variant_id) { transfer_item.variant.to_param }
|
65
|
-
|
66
|
-
before do
|
67
|
-
transfer_item.update_attributes!(expected_quantity: 1, received_quantity: 1)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns a 422" do
|
71
|
-
subject
|
72
|
-
expect(response.status).to eq 422
|
73
|
-
end
|
74
|
-
|
75
|
-
it "returns a specific error message" do
|
76
|
-
subject
|
77
|
-
expect(JSON.parse(response.body)["errors"]["received_quantity"]).to eq ["must be less than or equal to 1"]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "variant is not in the transfer order" do
|
82
|
-
let(:variant_id) { create(:variant).to_param }
|
83
|
-
|
84
|
-
it "returns a 422" do
|
85
|
-
subject
|
86
|
-
expect(response.status).to eq 422
|
87
|
-
end
|
88
|
-
|
89
|
-
it "returns a specific error message" do
|
90
|
-
subject
|
91
|
-
expect(JSON.parse(response.body)["error"]).to eq Spree.t(:item_not_in_stock_transfer)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
describe Api::TransferItemsController do
|
5
|
-
|
6
|
-
let!(:stock_transfer) { create(:stock_transfer_with_items) }
|
7
|
-
let(:transfer_item) { stock_transfer.transfer_items.first }
|
8
|
-
|
9
|
-
before do
|
10
|
-
stub_authentication!
|
11
|
-
end
|
12
|
-
|
13
|
-
context "as a normal user" do
|
14
|
-
describe "#create" do
|
15
|
-
it "cannot create a transfer item" do
|
16
|
-
post spree.api_stock_transfer_transfer_items_path(stock_transfer)
|
17
|
-
expect(response.status).to eq 401
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#update" do
|
22
|
-
it "cannot update a transfer item" do
|
23
|
-
put spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item)
|
24
|
-
expect(response.status).to eq 401
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#destroy" do
|
29
|
-
it "cannot delete a transfer item" do
|
30
|
-
delete spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item)
|
31
|
-
expect(response.status).to eq 401
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "as an admin" do
|
37
|
-
sign_in_as_admin!
|
38
|
-
|
39
|
-
describe "#create" do
|
40
|
-
subject do
|
41
|
-
create_params = {
|
42
|
-
transfer_item: {
|
43
|
-
variant_id: variant_id,
|
44
|
-
expected_quantity: 1
|
45
|
-
}
|
46
|
-
}
|
47
|
-
post spree.api_stock_transfer_transfer_items_path(stock_transfer), params: create_params
|
48
|
-
end
|
49
|
-
|
50
|
-
context "valid parameters" do
|
51
|
-
let(:variant) { create(:variant) }
|
52
|
-
let(:variant_id) { variant.id }
|
53
|
-
|
54
|
-
context "variant is available" do
|
55
|
-
before do
|
56
|
-
variant.stock_items.update_all(count_on_hand: 1)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "can create a transfer item" do
|
60
|
-
subject
|
61
|
-
expect(response.status).to eq 201
|
62
|
-
end
|
63
|
-
|
64
|
-
it "creates a transfer item" do
|
65
|
-
expect { subject }.to change { Spree::TransferItem.count }.by(1)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "variant is not available" do
|
70
|
-
before do
|
71
|
-
variant.stock_items.update_all(count_on_hand: 0)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns an error status" do
|
75
|
-
subject
|
76
|
-
expect(response.status).to eq 422
|
77
|
-
end
|
78
|
-
|
79
|
-
it "does not create a transfer item" do
|
80
|
-
expect { subject }.to_not change { Spree::TransferItem.count }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#update" do
|
87
|
-
subject do
|
88
|
-
update_params = { transfer_item: { received_quantity: received_quantity } }
|
89
|
-
put spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item), params: update_params
|
90
|
-
end
|
91
|
-
|
92
|
-
context "valid parameters" do
|
93
|
-
let(:received_quantity) { 2 }
|
94
|
-
|
95
|
-
it "can update a transfer item" do
|
96
|
-
subject
|
97
|
-
expect(response.status).to eq 200
|
98
|
-
end
|
99
|
-
|
100
|
-
it "updates the transfer item" do
|
101
|
-
expect { subject }.to change { transfer_item.reload.received_quantity }.to(2)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context "invalid parameters" do
|
106
|
-
let(:received_quantity) { -5 }
|
107
|
-
|
108
|
-
it "returns a 422" do
|
109
|
-
subject
|
110
|
-
expect(response.status).to eq 422
|
111
|
-
end
|
112
|
-
|
113
|
-
it "does not update the transfer item" do
|
114
|
-
expect { subject }.to_not change { transfer_item.reload.received_quantity }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#destroy" do
|
120
|
-
subject { delete spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item) }
|
121
|
-
|
122
|
-
context "hasn't been finalized" do
|
123
|
-
it "can delete a transfer item" do
|
124
|
-
subject
|
125
|
-
expect(response.status).to eq 200
|
126
|
-
end
|
127
|
-
|
128
|
-
it "deletes the transfer item" do
|
129
|
-
expect { subject }.to change { Spree::TransferItem.count }.by(-1)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "has been finalized" do
|
134
|
-
before do
|
135
|
-
stock_transfer.update_attributes(finalized_at: Time.current)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "returns an error status code" do
|
139
|
-
subject
|
140
|
-
expect(response.status).to eq 422
|
141
|
-
end
|
142
|
-
|
143
|
-
it "does not delete the transfer item" do
|
144
|
-
expect { subject }.to_not change { Spree::TransferItem.count }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|