spree_api 3.7.0.rc3 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spree_api might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/v2/base_controller.rb +7 -3
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +40 -0
- data/app/models/spree/api_configuration.rb +1 -0
- data/config/initializers/json_api_mime_types.rb +8 -0
- data/config/routes.rb +1 -0
- data/docs/v2/storefront/index.yaml +63 -43
- data/lib/spree/api/testing_support/v2/base.rb +13 -0
- data/lib/spree/api/testing_support/v2/current_order.rb +73 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44cc06b0850a333645e6a6d2bf64cf12f4027c00c384d63b93cb5f300e078d24
|
4
|
+
data.tar.gz: b4afc56d8582365d30138740d9801048204f41a457b8586ecab81e2bda551d41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d23e8bf8132452698c0a7e5e837e4c602786ffc6643b4816d9f9b800c86411fd89c73acab7caf67dd13a547d562a8135260bb4603e7d54cc6c93ba2ca790ef5
|
7
|
+
data.tar.gz: d8c110fd93c97c51e03d02c8783ae232afdf18227fe9c6ae8a6b7aba755d4638b004a3af6760953dbc67089850cce19923beb498761f6a855e25aaed8699e334
|
@@ -7,6 +7,10 @@ module Spree
|
|
7
7
|
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
8
8
|
rescue_from CanCan::AccessDenied, with: :access_denied
|
9
9
|
|
10
|
+
def content_type
|
11
|
+
Spree::Api::Config[:api_v2_content_type]
|
12
|
+
end
|
13
|
+
|
10
14
|
private
|
11
15
|
|
12
16
|
def collection_paginator
|
@@ -14,16 +18,16 @@ module Spree
|
|
14
18
|
end
|
15
19
|
|
16
20
|
def render_serialized_payload(status = 200)
|
17
|
-
render json: yield, status: status
|
21
|
+
render json: yield, status: status, content_type: content_type
|
18
22
|
rescue ArgumentError => exception
|
19
23
|
render_error_payload(exception.message, 400)
|
20
24
|
end
|
21
25
|
|
22
26
|
def render_error_payload(error, status = 422)
|
23
27
|
if error.is_a?(Struct)
|
24
|
-
render json: { error: error.to_s, errors: error.to_h }, status: status
|
28
|
+
render json: { error: error.to_s, errors: error.to_h }, status: status, content_type: content_type
|
25
29
|
elsif error.is_a?(String)
|
26
|
-
render json: { error: error }, status: status
|
30
|
+
render json: { error: error }, status: status, content_type: content_type
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class OrderStatusController < ::Spree::Api::V2::BaseController
|
6
|
+
include Spree::Api::V2::Storefront::OrderConcern
|
7
|
+
|
8
|
+
def show
|
9
|
+
render_serialized_payload { serialize_resource(resource) }
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def resource
|
15
|
+
resource = resource_finder.new(number: params[:number], token: order_token).execute.take
|
16
|
+
raise ActiveRecord::RecordNotFound if resource.nil?
|
17
|
+
|
18
|
+
resource
|
19
|
+
end
|
20
|
+
|
21
|
+
def serialize_resource(resource)
|
22
|
+
resource_serializer.new(
|
23
|
+
resource,
|
24
|
+
include: resource_includes,
|
25
|
+
sparse_fields: sparse_fields
|
26
|
+
).serializable_hash
|
27
|
+
end
|
28
|
+
|
29
|
+
def resource_finder
|
30
|
+
Spree::Api::Dependencies.storefront_completed_order_finder.constantize
|
31
|
+
end
|
32
|
+
|
33
|
+
def resource_serializer
|
34
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/config/routes.rb
CHANGED
@@ -158,6 +158,7 @@ Spree::Core::Engine.add_routes do
|
|
158
158
|
|
159
159
|
resources :countries, only: %i[index]
|
160
160
|
get '/countries/:iso', to: 'countries#show', as: :country
|
161
|
+
get '/order_status/:number', to: 'order_status#show', as: :order_status
|
161
162
|
resources :products, only: %i[index show]
|
162
163
|
resources :taxons, only: %i[index show]
|
163
164
|
end
|
@@ -34,7 +34,7 @@ paths:
|
|
34
34
|
'200':
|
35
35
|
description: ok
|
36
36
|
content:
|
37
|
-
application/json:
|
37
|
+
application/vnd.api+json:
|
38
38
|
schema:
|
39
39
|
$ref: '#/components/schemas/Account'
|
40
40
|
'403':
|
@@ -53,7 +53,7 @@ paths:
|
|
53
53
|
'200':
|
54
54
|
description: Listing user credit cards.
|
55
55
|
content:
|
56
|
-
application/json:
|
56
|
+
application/vnd.api+json:
|
57
57
|
schema:
|
58
58
|
$ref: '#/components/schemas/CreditCardList'
|
59
59
|
'403':
|
@@ -80,7 +80,7 @@ paths:
|
|
80
80
|
'200':
|
81
81
|
description: Listing user default credit card.
|
82
82
|
content:
|
83
|
-
application/json:
|
83
|
+
application/vnd.api+json:
|
84
84
|
schema:
|
85
85
|
$ref: '#/components/schemas/CreditCard'
|
86
86
|
'403':
|
@@ -100,7 +100,7 @@ paths:
|
|
100
100
|
'200':
|
101
101
|
description: Listing user completed orders.
|
102
102
|
content:
|
103
|
-
application/json:
|
103
|
+
application/vnd.api+json:
|
104
104
|
schema:
|
105
105
|
$ref: '#/components/schemas/CartList'
|
106
106
|
'403':
|
@@ -123,7 +123,7 @@ paths:
|
|
123
123
|
'200':
|
124
124
|
description: Listing user completed order.
|
125
125
|
content:
|
126
|
-
application/json:
|
126
|
+
application/vnd.api+json:
|
127
127
|
schema:
|
128
128
|
$ref: '#/components/schemas/Cart'
|
129
129
|
'403':
|
@@ -134,6 +134,26 @@ paths:
|
|
134
134
|
- $ref: '#/components/parameters/SparseFieldsParam'
|
135
135
|
security:
|
136
136
|
- bearerAuth: []
|
137
|
+
'/order_status/{number}':
|
138
|
+
get:
|
139
|
+
description: >-
|
140
|
+
Returns placed Order
|
141
|
+
tags:
|
142
|
+
- Order Status
|
143
|
+
operationId: 'Order Status'
|
144
|
+
responses:
|
145
|
+
'200':
|
146
|
+
description: Requested Order information
|
147
|
+
content:
|
148
|
+
application/json:
|
149
|
+
schema:
|
150
|
+
$ref: '#/components/schemas/Cart'
|
151
|
+
'404':
|
152
|
+
$ref: '#/components/responses/404NotFound'
|
153
|
+
parameters:
|
154
|
+
- $ref: '#/components/parameters/OrderParam'
|
155
|
+
- $ref: '#/components/parameters/CartIncludeParam'
|
156
|
+
- $ref: '#/components/parameters/SparseFieldsParam'
|
137
157
|
'/cart':
|
138
158
|
post:
|
139
159
|
description: >-
|
@@ -150,7 +170,7 @@ paths:
|
|
150
170
|
'201':
|
151
171
|
description: Cart was successfully created
|
152
172
|
content:
|
153
|
-
application/json:
|
173
|
+
application/vnd.api+json:
|
154
174
|
schema:
|
155
175
|
$ref: '#/components/schemas/Cart'
|
156
176
|
parameters:
|
@@ -165,7 +185,7 @@ paths:
|
|
165
185
|
'200':
|
166
186
|
description: Correct cart was returned
|
167
187
|
content:
|
168
|
-
application/json:
|
188
|
+
application/vnd.api+json:
|
169
189
|
schema:
|
170
190
|
$ref: '#/components/schemas/Cart'
|
171
191
|
'404':
|
@@ -197,7 +217,7 @@ paths:
|
|
197
217
|
'200':
|
198
218
|
description: Item was added to the Cart successfully
|
199
219
|
content:
|
200
|
-
application/json:
|
220
|
+
application/vnd.api+json:
|
201
221
|
schema:
|
202
222
|
$ref: '#/components/schemas/Cart'
|
203
223
|
'404':
|
@@ -211,7 +231,7 @@ paths:
|
|
211
231
|
requestBody:
|
212
232
|
required: true
|
213
233
|
content:
|
214
|
-
application/json:
|
234
|
+
application/vnd.api+json:
|
215
235
|
schema:
|
216
236
|
type: object
|
217
237
|
properties:
|
@@ -240,13 +260,13 @@ paths:
|
|
240
260
|
'200':
|
241
261
|
description: New quantity has been successfully set for a requested Line Item
|
242
262
|
content:
|
243
|
-
application/json:
|
263
|
+
application/vnd.api+json:
|
244
264
|
schema:
|
245
265
|
$ref: '#/components/schemas/Cart'
|
246
266
|
'422':
|
247
267
|
description: Stock quantity is not sufficient for this request to be fulfielled
|
248
268
|
content:
|
249
|
-
application/json:
|
269
|
+
application/vnd.api+json:
|
250
270
|
schema:
|
251
271
|
$ref: '#/components/schemas/Error'
|
252
272
|
security:
|
@@ -258,7 +278,7 @@ paths:
|
|
258
278
|
requestBody:
|
259
279
|
required: true
|
260
280
|
content:
|
261
|
-
application/json:
|
281
|
+
application/vnd.api+json:
|
262
282
|
schema:
|
263
283
|
type: object
|
264
284
|
properties:
|
@@ -284,7 +304,7 @@ paths:
|
|
284
304
|
'200':
|
285
305
|
description: Requested Line Item has been removed from the Cart
|
286
306
|
content:
|
287
|
-
application/json:
|
307
|
+
application/vnd.api+json:
|
288
308
|
schema:
|
289
309
|
$ref: '#/components/schemas/Cart'
|
290
310
|
'404':
|
@@ -303,7 +323,7 @@ paths:
|
|
303
323
|
'200':
|
304
324
|
description: Cart has been successfully emptied
|
305
325
|
content:
|
306
|
-
application/json:
|
326
|
+
application/vnd.api+json:
|
307
327
|
schema:
|
308
328
|
$ref: '#/components/schemas/Cart'
|
309
329
|
'404':
|
@@ -325,13 +345,13 @@ paths:
|
|
325
345
|
'200':
|
326
346
|
description: Cuopon code was applied successfully
|
327
347
|
content:
|
328
|
-
application/json:
|
348
|
+
application/vnd.api+json:
|
329
349
|
schema:
|
330
350
|
$ref: '#/components/schemas/Cart'
|
331
351
|
'422':
|
332
352
|
description: Coupon code couldn't be applied
|
333
353
|
content:
|
334
|
-
application/json:
|
354
|
+
application/vnd.api+json:
|
335
355
|
schema:
|
336
356
|
$ref: '#/components/schemas/Error'
|
337
357
|
security:
|
@@ -343,7 +363,7 @@ paths:
|
|
343
363
|
requestBody:
|
344
364
|
required: true
|
345
365
|
content:
|
346
|
-
application/json:
|
366
|
+
application/vnd.api+json:
|
347
367
|
schema:
|
348
368
|
type: object
|
349
369
|
properties:
|
@@ -371,13 +391,13 @@ paths:
|
|
371
391
|
'200':
|
372
392
|
description: Coupon code was removed successfully
|
373
393
|
content:
|
374
|
-
application/json:
|
394
|
+
application/vnd.api+json:
|
375
395
|
schema:
|
376
396
|
$ref: '#/components/schemas/Cart'
|
377
397
|
'422':
|
378
398
|
description: Coupon code couldn't be removed
|
379
399
|
content:
|
380
|
-
application/json:
|
400
|
+
application/vnd.api+json:
|
381
401
|
schema:
|
382
402
|
$ref: '#/components/schemas/Error'
|
383
403
|
security:
|
@@ -496,13 +516,13 @@ paths:
|
|
496
516
|
'200':
|
497
517
|
description: Checkout was updated
|
498
518
|
content:
|
499
|
-
application/json:
|
519
|
+
application/vnd.api+json:
|
500
520
|
schema:
|
501
521
|
$ref: '#/components/schemas/Cart'
|
502
522
|
'422':
|
503
523
|
description: Checkout couldn't be updated
|
504
524
|
content:
|
505
|
-
application/json:
|
525
|
+
application/vnd.api+json:
|
506
526
|
schema:
|
507
527
|
$ref: '#/components/schemas/Error'
|
508
528
|
'404':
|
@@ -515,7 +535,7 @@ paths:
|
|
515
535
|
requestBody:
|
516
536
|
required: true
|
517
537
|
content:
|
518
|
-
application/json:
|
538
|
+
application/vnd.api+json:
|
519
539
|
schema:
|
520
540
|
type: object
|
521
541
|
properties:
|
@@ -553,13 +573,13 @@ paths:
|
|
553
573
|
'200':
|
554
574
|
description: Checkout transitioned to the next step
|
555
575
|
content:
|
556
|
-
application/json:
|
576
|
+
application/vnd.api+json:
|
557
577
|
schema:
|
558
578
|
$ref: '#/components/schemas/Cart'
|
559
579
|
'422':
|
560
580
|
description: Checkout couldn't transition to the next step
|
561
581
|
content:
|
562
|
-
application/json:
|
582
|
+
application/vnd.api+json:
|
563
583
|
schema:
|
564
584
|
$ref: '#/components/schemas/Error'
|
565
585
|
'404':
|
@@ -581,13 +601,13 @@ paths:
|
|
581
601
|
'200':
|
582
602
|
description: Checkout was advanced to the furthest step
|
583
603
|
content:
|
584
|
-
application/json:
|
604
|
+
application/vnd.api+json:
|
585
605
|
schema:
|
586
606
|
$ref: '#/components/schemas/Cart'
|
587
607
|
'422':
|
588
608
|
description: Checkout couldn't transition to the next step
|
589
609
|
content:
|
590
|
-
application/json:
|
610
|
+
application/vnd.api+json:
|
591
611
|
schema:
|
592
612
|
$ref: '#/components/schemas/Error'
|
593
613
|
'404':
|
@@ -609,13 +629,13 @@ paths:
|
|
609
629
|
'200':
|
610
630
|
description: Checkout was completed
|
611
631
|
content:
|
612
|
-
application/json:
|
632
|
+
application/vnd.api+json:
|
613
633
|
schema:
|
614
634
|
$ref: '#/components/schemas/Cart'
|
615
635
|
'422':
|
616
636
|
description: Checkout couldn't be completed
|
617
637
|
content:
|
618
|
-
application/json:
|
638
|
+
application/vnd.api+json:
|
619
639
|
schema:
|
620
640
|
$ref: '#/components/schemas/Error'
|
621
641
|
'404':
|
@@ -636,13 +656,13 @@ paths:
|
|
636
656
|
'200':
|
637
657
|
description: Store Credit payment created
|
638
658
|
content:
|
639
|
-
application/json:
|
659
|
+
application/vnd.api+json:
|
640
660
|
schema:
|
641
661
|
$ref: '#/components/schemas/Cart'
|
642
662
|
'422':
|
643
663
|
description: Store Credit couldn't be created
|
644
664
|
content:
|
645
|
-
application/json:
|
665
|
+
application/vnd.api+json:
|
646
666
|
schema:
|
647
667
|
$ref: '#/components/schemas/Error'
|
648
668
|
'404':
|
@@ -671,13 +691,13 @@ paths:
|
|
671
691
|
'200':
|
672
692
|
description: Store Credit payment removed
|
673
693
|
content:
|
674
|
-
application/json:
|
694
|
+
application/vnd.api+json:
|
675
695
|
schema:
|
676
696
|
$ref: '#/components/schemas/Cart'
|
677
697
|
'422':
|
678
698
|
description: Store Credit payments weren't removed
|
679
699
|
content:
|
680
|
-
application/json:
|
700
|
+
application/vnd.api+json:
|
681
701
|
schema:
|
682
702
|
$ref: '#/components/schemas/Error'
|
683
703
|
'404':
|
@@ -700,7 +720,7 @@ paths:
|
|
700
720
|
'200':
|
701
721
|
description: Returns a list of available Payment Methods
|
702
722
|
content:
|
703
|
-
application/json:
|
723
|
+
application/vnd.api+json:
|
704
724
|
schema:
|
705
725
|
$ref: '#/components/schemas/PaymentMethodsList'
|
706
726
|
'404':
|
@@ -723,7 +743,7 @@ paths:
|
|
723
743
|
'200':
|
724
744
|
description: Returns a list of available Shipping Rates for Checkout
|
725
745
|
content:
|
726
|
-
application/json:
|
746
|
+
application/vnd.api+json:
|
727
747
|
schema:
|
728
748
|
$ref: '#/components/schemas/ShippingRatesList'
|
729
749
|
'404':
|
@@ -788,7 +808,7 @@ paths:
|
|
788
808
|
'200':
|
789
809
|
description: Returns a list of Products
|
790
810
|
content:
|
791
|
-
application/json:
|
811
|
+
application/vnd.api+json:
|
792
812
|
schema:
|
793
813
|
$ref: '#/components/schemas/ProductsList'
|
794
814
|
'/products/{id}':
|
@@ -810,7 +830,7 @@ paths:
|
|
810
830
|
'200':
|
811
831
|
description: Returns the requested Product
|
812
832
|
content:
|
813
|
-
application/json:
|
833
|
+
application/vnd.api+json:
|
814
834
|
schema:
|
815
835
|
$ref: '#/components/schemas/Product'
|
816
836
|
'404':
|
@@ -852,7 +872,7 @@ paths:
|
|
852
872
|
'200':
|
853
873
|
description: Returns a list of Taxons
|
854
874
|
content:
|
855
|
-
application/json:
|
875
|
+
application/vnd.api+json:
|
856
876
|
schema:
|
857
877
|
$ref: '#/components/schemas/TaxonsList'
|
858
878
|
|
@@ -875,7 +895,7 @@ paths:
|
|
875
895
|
'200':
|
876
896
|
description: Returns the reqested Taxon
|
877
897
|
content:
|
878
|
-
application/json:
|
898
|
+
application/vnd.api+json:
|
879
899
|
schema:
|
880
900
|
$ref: '#/components/schemas/Taxon'
|
881
901
|
'404':
|
@@ -892,7 +912,7 @@ paths:
|
|
892
912
|
'200':
|
893
913
|
description: Returns a list of all Countries
|
894
914
|
content:
|
895
|
-
application/json:
|
915
|
+
application/vnd.api+json:
|
896
916
|
schema:
|
897
917
|
$ref: '#/components/schemas/CountriesList'
|
898
918
|
|
@@ -915,7 +935,7 @@ paths:
|
|
915
935
|
'200':
|
916
936
|
description: Returns the requested Country
|
917
937
|
content:
|
918
|
-
application/json:
|
938
|
+
application/vnd.api+json:
|
919
939
|
schema:
|
920
940
|
$ref: '#/components/schemas/Country'
|
921
941
|
'404':
|
@@ -936,7 +956,7 @@ paths:
|
|
936
956
|
'200':
|
937
957
|
description: Returns the default Country
|
938
958
|
content:
|
939
|
-
application/json:
|
959
|
+
application/vnd.api+json:
|
940
960
|
schema:
|
941
961
|
$ref: '#/components/schemas/Country'
|
942
962
|
|
@@ -2528,7 +2548,7 @@ components:
|
|
2528
2548
|
404NotFound:
|
2529
2549
|
description: Resource not found
|
2530
2550
|
content:
|
2531
|
-
application/json:
|
2551
|
+
application/vnd.api+json:
|
2532
2552
|
schema:
|
2533
2553
|
properties:
|
2534
2554
|
error:
|
@@ -2538,7 +2558,7 @@ components:
|
|
2538
2558
|
403Forbidden:
|
2539
2559
|
description: You are not authorized to access this page.
|
2540
2560
|
content:
|
2541
|
-
application/json:
|
2561
|
+
application/vnd.api+json:
|
2542
2562
|
schema:
|
2543
2563
|
properties:
|
2544
2564
|
error:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
shared_context 'API v2 tokens' do
|
2
|
+
let(:token) { Doorkeeper::AccessToken.create!(resource_owner_id: user.id, expires_in: nil) }
|
3
|
+
let(:headers_bearer) { { 'Authorization' => "Bearer #{token.token}" } }
|
4
|
+
let(:headers_order_token) { { 'X-Spree-Order-Token' => order.token } }
|
5
|
+
end
|
6
|
+
|
7
|
+
[200, 201, 400, 404, 403, 422].each do |status_code|
|
8
|
+
shared_examples "returns #{status_code} HTTP status" do
|
9
|
+
it "returns #{status_code}" do
|
10
|
+
expect(response.status).to eq(status_code)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
def ensure_order_totals
|
2
|
+
order.update_totals
|
3
|
+
order.persist_totals
|
4
|
+
end
|
5
|
+
|
6
|
+
shared_context 'creates order with line item' do
|
7
|
+
let!(:line_item) { create(:line_item, order: order, currency: currency) }
|
8
|
+
let!(:headers) { headers_bearer }
|
9
|
+
|
10
|
+
before { ensure_order_totals }
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_context 'creates guest order with guest token' do
|
14
|
+
let(:guest_token) { 'guest_token' }
|
15
|
+
let!(:order) { create(:order, token: guest_token, store: store, currency: currency) }
|
16
|
+
let!(:line_item) { create(:line_item, order: order, currency: currency) }
|
17
|
+
let!(:headers) { headers_order_token }
|
18
|
+
|
19
|
+
before { ensure_order_totals }
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_examples 'returns valid cart JSON' do
|
23
|
+
it 'returns a valid cart JSON response' do
|
24
|
+
order.reload
|
25
|
+
expect(json_response['data']).to be_present
|
26
|
+
expect(json_response['data']).to have_id(order.id.to_s)
|
27
|
+
expect(json_response['data']).to have_type('cart')
|
28
|
+
expect(json_response['data']).to have_attribute(:number).with_value(order.number)
|
29
|
+
expect(json_response['data']).to have_attribute(:state).with_value(order.state)
|
30
|
+
expect(json_response['data']).to have_attribute(:token).with_value(order.token)
|
31
|
+
expect(json_response['data']).to have_attribute(:total).with_value(order.total.to_s)
|
32
|
+
expect(json_response['data']).to have_attribute(:item_total).with_value(order.item_total.to_s)
|
33
|
+
expect(json_response['data']).to have_attribute(:ship_total).with_value(order.ship_total.to_s)
|
34
|
+
expect(json_response['data']).to have_attribute(:adjustment_total).with_value(order.adjustment_total.to_s)
|
35
|
+
expect(json_response['data']).to have_attribute(:included_tax_total).with_value(order.included_tax_total.to_s)
|
36
|
+
expect(json_response['data']).to have_attribute(:additional_tax_total).with_value(order.additional_tax_total.to_s)
|
37
|
+
expect(json_response['data']).to have_attribute(:display_additional_tax_total).with_value(order.display_additional_tax_total.to_s)
|
38
|
+
expect(json_response['data']).to have_attribute(:display_included_tax_total).with_value(order.display_included_tax_total.to_s)
|
39
|
+
expect(json_response['data']).to have_attribute(:tax_total).with_value(order.tax_total.to_s)
|
40
|
+
expect(json_response['data']).to have_attribute(:currency).with_value(order.currency.to_s)
|
41
|
+
expect(json_response['data']).to have_attribute(:email).with_value(order.email)
|
42
|
+
expect(json_response['data']).to have_attribute(:display_item_total).with_value(order.display_item_total.to_s)
|
43
|
+
expect(json_response['data']).to have_attribute(:display_ship_total).with_value(order.display_ship_total.to_s)
|
44
|
+
expect(json_response['data']).to have_attribute(:display_adjustment_total).with_value(order.display_adjustment_total.to_s)
|
45
|
+
expect(json_response['data']).to have_attribute(:display_tax_total).with_value(order.display_tax_total.to_s)
|
46
|
+
expect(json_response['data']).to have_attribute(:item_count).with_value(order.item_count)
|
47
|
+
expect(json_response['data']).to have_attribute(:special_instructions).with_value(order.special_instructions)
|
48
|
+
expect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s)
|
49
|
+
expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s)
|
50
|
+
expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s)
|
51
|
+
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
shared_examples 'no current order' do
|
56
|
+
context "order doesn't exist" do
|
57
|
+
before do
|
58
|
+
order.destroy
|
59
|
+
execute
|
60
|
+
end
|
61
|
+
|
62
|
+
it_behaves_like 'returns 404 HTTP status'
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'already completed order' do
|
66
|
+
before do
|
67
|
+
order.update_column(:completed_at, Time.current)
|
68
|
+
execute
|
69
|
+
end
|
70
|
+
|
71
|
+
it_behaves_like 'returns 404 HTTP status'
|
72
|
+
end
|
73
|
+
end
|
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.7.0
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.7.0
|
33
|
+
version: 3.7.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.7.0
|
40
|
+
version: 3.7.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rabl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- app/controllers/spree/api/v2/storefront/cart_controller.rb
|
149
149
|
- app/controllers/spree/api/v2/storefront/checkout_controller.rb
|
150
150
|
- app/controllers/spree/api/v2/storefront/countries_controller.rb
|
151
|
+
- app/controllers/spree/api/v2/storefront/order_status_controller.rb
|
151
152
|
- app/controllers/spree/api/v2/storefront/products_controller.rb
|
152
153
|
- app/controllers/spree/api/v2/storefront/taxons_controller.rb
|
153
154
|
- app/helpers/spree/api/api_helpers.rb
|
@@ -282,6 +283,7 @@ files:
|
|
282
283
|
- app/views/spree/api/v1/zones/index.v1.rabl
|
283
284
|
- app/views/spree/api/v1/zones/show.v1.rabl
|
284
285
|
- config/initializers/doorkeeper.rb
|
286
|
+
- config/initializers/json_api_mime_types.rb
|
285
287
|
- config/initializers/metal_load_paths.rb
|
286
288
|
- config/initializers/user_class_extensions.rb
|
287
289
|
- config/locales/en.yml
|
@@ -301,6 +303,8 @@ files:
|
|
301
303
|
- lib/spree/api/testing_support/caching.rb
|
302
304
|
- lib/spree/api/testing_support/helpers.rb
|
303
305
|
- lib/spree/api/testing_support/setup.rb
|
306
|
+
- lib/spree/api/testing_support/v2/base.rb
|
307
|
+
- lib/spree/api/testing_support/v2/current_order.rb
|
304
308
|
- lib/spree_api.rb
|
305
309
|
- script/rails
|
306
310
|
- spec/fixtures/thinking-cat.jpg
|
@@ -320,9 +324,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
320
324
|
version: 2.3.3
|
321
325
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
322
326
|
requirements:
|
323
|
-
- - "
|
327
|
+
- - ">="
|
324
328
|
- !ruby/object:Gem::Version
|
325
|
-
version:
|
329
|
+
version: '0'
|
326
330
|
requirements: []
|
327
331
|
rubygems_version: 3.0.2
|
328
332
|
signing_key:
|