solidus_api 2.9.5 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -2
  3. data/app/controllers/spree/api/addresses_controller.rb +1 -1
  4. data/app/controllers/spree/api/base_controller.rb +10 -10
  5. data/app/controllers/spree/api/checkouts_controller.rb +21 -8
  6. data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
  7. data/app/controllers/spree/api/images_controller.rb +1 -1
  8. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  9. data/app/controllers/spree/api/option_types_controller.rb +1 -1
  10. data/app/controllers/spree/api/option_values_controller.rb +1 -1
  11. data/app/controllers/spree/api/orders_controller.rb +17 -6
  12. data/app/controllers/spree/api/payments_controller.rb +1 -1
  13. data/app/controllers/spree/api/product_properties_controller.rb +1 -1
  14. data/app/controllers/spree/api/properties_controller.rb +1 -1
  15. data/app/controllers/spree/api/resource_controller.rb +1 -1
  16. data/app/controllers/spree/api/return_authorizations_controller.rb +1 -1
  17. data/app/controllers/spree/api/shipments_controller.rb +1 -1
  18. data/app/controllers/spree/api/stock_items_controller.rb +1 -1
  19. data/app/controllers/spree/api/stock_locations_controller.rb +1 -1
  20. data/app/controllers/spree/api/stores_controller.rb +1 -1
  21. data/app/controllers/spree/api/taxonomies_controller.rb +4 -2
  22. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  23. data/app/controllers/spree/api/variants_controller.rb +1 -1
  24. data/app/controllers/spree/api/zones_controller.rb +1 -1
  25. data/app/helpers/spree/api/api_helpers.rb +2 -2
  26. data/app/views/spree/api/images/_image.json.jbuilder +2 -2
  27. data/app/views/spree/api/orders/_order.json.jbuilder +1 -1
  28. data/app/views/spree/api/shared/_pagination.json.jbuilder +1 -1
  29. data/lib/spree/api.rb +0 -7
  30. data/lib/spree/api/config.rb +9 -0
  31. data/lib/spree/api/engine.rb +4 -4
  32. data/lib/spree/api/responders.rb +3 -2
  33. data/lib/spree/api/responders/{rabl_template.rb → jbuilder_template.rb} +3 -1
  34. data/{app/models → lib}/spree/api_configuration.rb +0 -0
  35. data/openapi/.stoplight.yml +7 -0
  36. data/openapi/api.oas2.yml +6108 -0
  37. data/openapi/authentication.md +25 -0
  38. data/openapi/checkout-flow.md +50 -0
  39. data/openapi/errors.md +3 -0
  40. data/openapi/lint.yml +1 -0
  41. data/openapi/main.hub.yml +65 -0
  42. data/openapi/pagination.md +7 -0
  43. data/openapi/theme.css +0 -0
  44. data/solidus_api.gemspec +1 -1
  45. data/spec/controllers/spree/api/resource_controller_spec.rb +4 -4
  46. data/spec/lib/spree_api_responders_spec.rb +10 -0
  47. data/spec/requests/api/address_books_spec.rb +2 -2
  48. data/spec/requests/{rabl_cache_spec.rb → jbuilder_cache_spec.rb} +2 -2
  49. data/spec/requests/spree/api/checkouts_controller_spec.rb +35 -7
  50. data/spec/requests/spree/api/classifications_controller_spec.rb +1 -1
  51. data/spec/requests/spree/api/option_types_controller_spec.rb +2 -2
  52. data/spec/requests/spree/api/option_values_controller_spec.rb +2 -2
  53. data/spec/requests/spree/api/orders_controller_spec.rb +38 -15
  54. data/spec/requests/spree/api/payments_controller_spec.rb +3 -3
  55. data/spec/requests/spree/api/products_controller_spec.rb +6 -6
  56. data/spec/requests/spree/api/stock_items_controller_spec.rb +5 -5
  57. data/spec/requests/spree/api/stock_locations_controller_spec.rb +4 -4
  58. data/spec/requests/spree/api/taxons_controller_spec.rb +2 -2
  59. metadata +21 -9
@@ -137,7 +137,7 @@ module Spree
137
137
  context "for a given payment" do
138
138
  context "updating" do
139
139
  it "can update" do
140
- payment.update_attributes(state: 'pending')
140
+ payment.update(state: 'pending')
141
141
  put spree.api_order_payment_path(order, payment), params: { payment: { amount: 2.01 } }
142
142
  expect(response.status).to eq(200)
143
143
  expect(payment.reload.amount).to eq(2.01)
@@ -145,14 +145,14 @@ module Spree
145
145
 
146
146
  context "update fails" do
147
147
  it "returns a 422 status when the amount is invalid" do
148
- payment.update_attributes(state: 'pending')
148
+ payment.update(state: 'pending')
149
149
  put spree.api_order_payment_path(order, payment), params: { payment: { amount: 'invalid' } }
150
150
  expect(response.status).to eq(422)
151
151
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
152
152
  end
153
153
 
154
154
  it "returns a 403 status when the payment is not pending" do
155
- payment.update_attributes(state: 'completed')
155
+ payment.update(state: 'completed')
156
156
  put spree.api_order_payment_path(order, payment), params: { payment: { amount: 2.01 } }
157
157
  expect(response.status).to eq(403)
158
158
  expect(json_response["error"]).to eq("This payment cannot be updated because it is completed.")
@@ -17,8 +17,8 @@ module Spree
17
17
  shipping_category_id: create(:shipping_category).id }
18
18
  end
19
19
  let(:attributes_for_variant) do
20
- h = attributes_for(:variant).except(:option_values, :product)
21
- h.merge({
20
+ attributes = attributes_for(:variant).except(:option_values, :product)
21
+ attributes.merge({
22
22
  options: [
23
23
  { name: "size", value: "small" },
24
24
  { name: "color", value: "black" }
@@ -40,7 +40,7 @@ module Spree
40
40
 
41
41
  it "returns unique products" do
42
42
  get spree.api_products_path
43
- product_ids = json_response["products"].map { |p| p["id"] }
43
+ product_ids = json_response["products"].map { |product| product["id"] }
44
44
  expect(product_ids.uniq.count).to eq(product_ids.count)
45
45
  end
46
46
 
@@ -361,8 +361,8 @@ module Spree
361
361
  expect(response.status).to eq 200
362
362
  expect(json_response['variants'].count).to eq(2) # 2 variants
363
363
 
364
- variants = json_response['variants'].reject { |v| v['is_master'] }
365
- size_option_value = variants.last['option_values'].detect{ |x| x['option_type_name'] == 'size' }
364
+ variants = json_response['variants'].reject { |variant| variant['is_master'] }
365
+ size_option_value = variants.last['option_values'].detect{ |value| value['option_type_name'] == 'size' }
366
366
  expect(size_option_value['name']).to eq('small')
367
367
 
368
368
  expect(json_response['option_types'].count).to eq(2) # size, color
@@ -385,7 +385,7 @@ module Spree
385
385
  } }
386
386
 
387
387
  expect(json_response['variants'].count).to eq(1)
388
- variants = json_response['variants'].reject { |v| v['is_master'] }
388
+ variants = json_response['variants'].reject { |variant| variant['is_master'] }
389
389
  expect(variants.last['option_values'][0]['name']).to eq('large')
390
390
  expect(variants.last['sku']).to eq('456')
391
391
  expect(variants.count).to eq(1)
@@ -25,7 +25,7 @@ module Spree
25
25
  end
26
26
 
27
27
  it "cannot list stock items for an inactive stock location" do
28
- stock_location.update_attributes!(active: false)
28
+ stock_location.update!(active: false)
29
29
  get spree.api_stock_location_stock_items_path(stock_location)
30
30
  expect(response).to be_not_found
31
31
  end
@@ -39,7 +39,7 @@ module Spree
39
39
  end
40
40
 
41
41
  it "cannot see a stock item for an inactive stock location" do
42
- stock_location.update_attributes!(active: false)
42
+ stock_location.update!(active: false)
43
43
  get spree.api_stock_location_stock_item_path(stock_location, stock_item)
44
44
  expect(response.status).to eq(404)
45
45
  end
@@ -155,7 +155,7 @@ module Spree
155
155
 
156
156
  context 'variant does not track inventory' do
157
157
  before do
158
- variant.update_attributes(track_inventory: false)
158
+ variant.update(track_inventory: false)
159
159
  end
160
160
 
161
161
  it "doesn't set the stock item's count_on_hand" do
@@ -221,7 +221,7 @@ module Spree
221
221
 
222
222
  context 'not tracking inventory' do
223
223
  before do
224
- stock_item.variant.update_attributes(track_inventory: false)
224
+ stock_item.variant.update(track_inventory: false)
225
225
  end
226
226
 
227
227
  it "doesn't set the stock item's count_on_hand" do
@@ -279,7 +279,7 @@ module Spree
279
279
 
280
280
  context 'not tracking inventory' do
281
281
  before do
282
- stock_item.variant.update_attributes(track_inventory: false)
282
+ stock_item.variant.update(track_inventory: false)
283
283
  end
284
284
 
285
285
  it "doesn't update the stock item's count_on_hand" do
@@ -21,7 +21,7 @@ module Spree
21
21
  end
22
22
 
23
23
  it "cannot see inactive stock locations" do
24
- stock_location.update_attributes!(active: false)
24
+ stock_location.update!(active: false)
25
25
  get spree.api_stock_locations_path
26
26
  expect(response).to be_successful
27
27
  stock_locations = json_response['stock_locations'].map { |sl| sl['name'] }
@@ -37,7 +37,7 @@ module Spree
37
37
  end
38
38
 
39
39
  it "cannot see inactive stock locations" do
40
- stock_location.update_attributes!(active: false)
40
+ stock_location.update!(active: false)
41
41
  get spree.api_stock_location_path(stock_location)
42
42
  expect(response).to be_not_found
43
43
  end
@@ -84,7 +84,7 @@ module Spree
84
84
  end
85
85
 
86
86
  it "can see inactive stock locations" do
87
- stock_location.update_attributes!(active: false)
87
+ stock_location.update!(active: false)
88
88
  get spree.api_stock_locations_path
89
89
  expect(response).to be_successful
90
90
  stock_locations = json_response['stock_locations'].map { |sl| sl['name'] }
@@ -122,7 +122,7 @@ module Spree
122
122
  end
123
123
 
124
124
  it "can see inactive stock locations" do
125
- stock_location.update_attributes!(active: false)
125
+ stock_location.update!(active: false)
126
126
  get spree.api_stock_location_path(stock_location)
127
127
  expect(response).to be_successful
128
128
  expect(json_response['name']).to eq stock_location.name
@@ -93,9 +93,9 @@ module Spree
93
93
  it 'returns only requested ids' do
94
94
  # We need a completly new branch to avoid having parent that can be preloaded from the rails ancestors
95
95
  python = create(:taxon, name: "Python", parent: taxonomy.root, taxonomy: taxonomy)
96
- python_3 = create(:taxon, name: "3.0", parent: python, taxonomy: taxonomy)
96
+ python_three = create(:taxon, name: "3.0", parent: python, taxonomy: taxonomy)
97
97
 
98
- get spree.api_taxons_path, params: { ids: [rails_v3_2_2.id, python_3.id] }
98
+ get spree.api_taxons_path, params: { ids: [rails_v3_2_2.id, python_three.id] }
99
99
 
100
100
  expect(json_response['taxons'].size).to eq 2
101
101
  end
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.9.5
4
+ version: 2.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.9.5
61
+ version: 2.10.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.9.5
68
+ version: 2.10.2
69
69
  description: REST API for the Solidus e-commerce framework.
70
70
  email: contact@solidus.io
71
71
  executables: []
@@ -111,7 +111,6 @@ files:
111
111
  - app/controllers/spree/api/variants_controller.rb
112
112
  - app/controllers/spree/api/zones_controller.rb
113
113
  - app/helpers/spree/api/api_helpers.rb
114
- - app/models/spree/api_configuration.rb
115
114
  - app/views/.rubocop.yml
116
115
  - app/views/spree/api/address_books/show.json.jbuilder
117
116
  - app/views/spree/api/addresses/_address.json.jbuilder
@@ -230,22 +229,34 @@ files:
230
229
  - db/migrate/20131017162334_add_index_to_user_spree_api_key.rb
231
230
  - lib/solidus_api.rb
232
231
  - lib/spree/api.rb
232
+ - lib/spree/api/config.rb
233
233
  - lib/spree/api/engine.rb
234
234
  - lib/spree/api/responders.rb
235
- - lib/spree/api/responders/rabl_template.rb
235
+ - lib/spree/api/responders/jbuilder_template.rb
236
236
  - lib/spree/api/testing_support/caching.rb
237
237
  - lib/spree/api/testing_support/helpers.rb
238
238
  - lib/spree/api/testing_support/setup.rb
239
+ - lib/spree/api_configuration.rb
239
240
  - lib/spree_api.rb
241
+ - openapi/.stoplight.yml
242
+ - openapi/api.oas2.yml
243
+ - openapi/authentication.md
244
+ - openapi/checkout-flow.md
245
+ - openapi/errors.md
246
+ - openapi/lint.yml
247
+ - openapi/main.hub.yml
248
+ - openapi/pagination.md
249
+ - openapi/theme.css
240
250
  - script/rails
241
251
  - solidus_api.gemspec
242
252
  - spec/controllers/spree/api/base_controller_spec.rb
243
253
  - spec/controllers/spree/api/resource_controller_spec.rb
244
254
  - spec/features/checkout_spec.rb
245
255
  - spec/fixtures/thinking-cat.jpg
256
+ - spec/lib/spree_api_responders_spec.rb
246
257
  - spec/models/spree/legacy_user_spec.rb
247
258
  - spec/requests/api/address_books_spec.rb
248
- - spec/requests/rabl_cache_spec.rb
259
+ - spec/requests/jbuilder_cache_spec.rb
249
260
  - spec/requests/ransackable_attributes_spec.rb
250
261
  - spec/requests/spree/api/addresses_controller_spec.rb
251
262
  - spec/requests/spree/api/checkouts_controller_spec.rb
@@ -302,7 +313,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
313
  requirements:
303
314
  - - ">="
304
315
  - !ruby/object:Gem::Version
305
- version: 2.2.2
316
+ version: 2.4.0
306
317
  required_rubygems_version: !ruby/object:Gem::Requirement
307
318
  requirements:
308
319
  - - ">="
@@ -318,9 +329,10 @@ test_files:
318
329
  - spec/controllers/spree/api/resource_controller_spec.rb
319
330
  - spec/features/checkout_spec.rb
320
331
  - spec/fixtures/thinking-cat.jpg
332
+ - spec/lib/spree_api_responders_spec.rb
321
333
  - spec/models/spree/legacy_user_spec.rb
322
334
  - spec/requests/api/address_books_spec.rb
323
- - spec/requests/rabl_cache_spec.rb
335
+ - spec/requests/jbuilder_cache_spec.rb
324
336
  - spec/requests/ransackable_attributes_spec.rb
325
337
  - spec/requests/spree/api/addresses_controller_spec.rb
326
338
  - spec/requests/spree/api/checkouts_controller_spec.rb