solidus_api 2.8.6 → 2.9.0.rc.1

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 solidus_api might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04c64c177896dab37dae312ae08fd93f1c044ea416ad2ca7184dde05a5faeb5c
4
- data.tar.gz: cb6b60e062b48cb68fd5e73172015877ffe3ee84ebbb58b56ee58cf5844610df
3
+ metadata.gz: f072a9ee2804fcc901b86b39bcc46256c1bf9a150010b38f68f8b21482c1ac4b
4
+ data.tar.gz: ad1d4f5fa1e4eb2111c6487a440cac9de7c3eabd1389166c7473f28ecfbf85db
5
5
  SHA512:
6
- metadata.gz: c2d2e3c4df97047d23b464b722bc32d6efee403aba8f80891d31e896e15ccfd050a419329855209e31843cfc19283661cd6845857320d989edf718a6455a3223
7
- data.tar.gz: 521dc0e421fda8eb0bc9ef9dc7f029800bca98bae82889dee2cabe4a8d242341a285e528db58eed8613d41f5648fe0910f9593ad5505071a475f6cec7bab36c6
6
+ metadata.gz: 7977793990e1c7a1e2ef3327a8e0a1cbe251c684305a68cc75333401179ca2fdc94dfedf7c2fe28d3b8280fd0aed17c41f8467b14e6460a9729c3f4d971f138c
7
+ data.tar.gz: 1681331bc656cbc6922629217c138887774f0faca3d835797f7d35d960ae31422efbe0429f2bffdf14aaf924a9b2adb9576ddca4d5b13b1dab0426c395335c38
@@ -76,24 +76,11 @@ module Spree
76
76
  end
77
77
 
78
78
  def update_params
79
- state = @order.state
80
- case state.to_sym
81
- when :cart, :address
82
- massaged_params.fetch(:order, {}).permit(
83
- permitted_checkout_address_attributes
84
- )
85
- when :delivery
86
- massaged_params.require(:order).permit(
87
- permitted_checkout_delivery_attributes
88
- )
89
- when :payment
90
- massaged_params.require(:order).permit(
91
- permitted_checkout_payment_attributes
92
- )
79
+ if update_params = massaged_params[:order]
80
+ update_params.permit(permitted_checkout_attributes)
93
81
  else
94
- massaged_params.fetch(:order, {}).permit(
95
- permitted_checkout_confirm_attributes
96
- )
82
+ # We current allow update requests without any parameters in them.
83
+ {}
97
84
  end
98
85
  end
99
86
 
@@ -9,6 +9,9 @@ module Spree
9
9
  class_attribute :admin_order_attributes
10
10
  self.admin_order_attributes = [:import, :number, :completed_at, :locked_at, :channel, :user_id, :created_at]
11
11
 
12
+ class_attribute :admin_payment_attributes
13
+ self.admin_payment_attributes = [:payment_method, :amount, :state, source: {}]
14
+
12
15
  skip_before_action :authenticate_user, only: :apply_coupon_code
13
16
 
14
17
  before_action :find_order, except: [:create, :mine, :current, :index]
@@ -128,13 +131,7 @@ module Spree
128
131
  end
129
132
 
130
133
  def normalize_params
131
- if params[:order][:payments]
132
- payments_params = params[:order].delete(:payments)
133
- params[:order][:payments_attributes] = payments_params.map do |payment_params|
134
- payment_params[:source_attributes] = payment_params.delete(:source) if payment_params[:source].present?
135
- payment_params
136
- end
137
- end
134
+ params[:order][:payments_attributes] = params[:order].delete(:payments) if params[:order][:payments]
138
135
  params[:order][:shipments_attributes] = params[:order].delete(:shipments) if params[:order][:shipments]
139
136
  params[:order][:line_items_attributes] = params[:order].delete(:line_items) if params[:order][:line_items]
140
137
  params[:order][:ship_address_attributes] = params[:order].delete(:ship_address) if params[:order][:ship_address].present?
@@ -162,6 +159,14 @@ module Spree
162
159
  end
163
160
  end
164
161
 
162
+ def permitted_payment_attributes
163
+ if can?(:admin, Spree::Payment)
164
+ super + admin_payment_attributes
165
+ else
166
+ super
167
+ end
168
+ end
169
+
165
170
  def find_order(_lock = false)
166
171
  @order = Spree::Order.find_by!(number: params[:id])
167
172
  end
@@ -113,7 +113,7 @@ module Spree
113
113
  )
114
114
 
115
115
  if fulfilment_changer.run!
116
- render json: { success: true, message: t('spree.shipment_transfer_success') }, status: :accepted
116
+ render json: { success: true, message: t('spree.api.shipment.transfer_success') }, status: :accepted
117
117
  else
118
118
  render json: { success: false, message: fulfilment_changer.errors.full_messages.to_sentence }, status: :accepted
119
119
  end
@@ -131,11 +131,8 @@ module Spree
131
131
  end
132
132
 
133
133
  def find_order_on_create
134
- # TODO: Can remove conditional here once deprecated #find_order is removed.
135
- unless @order.present?
136
- @order = Spree::Order.find_by!(number: params[:shipment][:order_id])
137
- authorize! :read, @order
138
- end
134
+ @order = Spree::Order.find_by!(number: params[:shipment][:order_id])
135
+ authorize! :read, @order
139
136
  end
140
137
 
141
138
  def find_shipment
@@ -77,14 +77,14 @@ module Spree
77
77
 
78
78
  def adjust_stock_item_count_on_hand(count_on_hand_adjustment)
79
79
  if @stock_item.count_on_hand + count_on_hand_adjustment < 0
80
- raise StockLocation::InvalidMovementError.new(t('spree.stock_not_below_zero'))
80
+ raise StockLocation::InvalidMovementError.new(t('spree.api.stock_not_below_zero'))
81
81
  end
82
82
  @stock_movement = @stock_location.move(@stock_item.variant, count_on_hand_adjustment, current_api_user)
83
83
  @stock_item = @stock_movement.stock_item
84
84
  end
85
85
 
86
86
  def render_stock_items_error
87
- render json: { error: t('spree.stock_not_below_zero') }, status: 422
87
+ render json: { error: t('spree.api.stock_not_below_zero') }, status: 422
88
88
  end
89
89
  end
90
90
  end
@@ -51,7 +51,7 @@ module Spree
51
51
  end
52
52
 
53
53
  @@product_attributes = [
54
- :id, :name, :description, :price, :display_price, :available_on,
54
+ :id, :name, :description, :available_on,
55
55
  :slug, :meta_description, :meta_keywords, :shipping_category_id,
56
56
  :taxon_ids, :total_on_hand, :meta_title
57
57
  ]
@@ -61,7 +61,7 @@ module Spree
61
61
  ]
62
62
 
63
63
  @@variant_attributes = [
64
- :id, :name, :sku, :price, :weight, :height, :width, :depth, :is_master,
64
+ :id, :name, :sku, :weight, :height, :width, :depth, :is_master,
65
65
  :slug, :description, :track_inventory
66
66
  ]
67
67
 
@@ -183,6 +183,10 @@ module Spree
183
183
  @@variant_attributes
184
184
  end
185
185
  end
186
+
187
+ def total_on_hand_for(object)
188
+ object.total_on_hand.finite? ? object.total_on_hand : nil
189
+ end
186
190
  end
187
191
  end
188
192
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.error(I18n.t(:invalid_api_key, key: api_key, scope: "spree.api"))
3
+ json.error(I18n.t('spree.api.invalid_api_key', key: api_key))
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.error(I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: "spree.api.payment"))
3
+ json.error(I18n.t('spree.api.payment.credit_over_limit', limit: @payment.credit_allowed))
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.error(I18n.t(:update_forbidden, state: @payment.state, scope: "spree.api.payment"))
3
+ json.error(I18n.t('spree.api.payment.update_forbidden', state: @payment.state))
@@ -2,8 +2,10 @@
2
2
 
3
3
  @product_attributes ||= product_attributes
4
4
  json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do
5
- json.(product, *@product_attributes)
6
- json.display_price(product.display_price.to_s)
5
+ json.(product, *(@product_attributes - [:total_on_hand]))
6
+ json.total_on_hand(total_on_hand_for(product))
7
+ json.price(product.price_for(current_pricing_options).try(:to_d))
8
+ json.display_price(product.price_for(current_pricing_options).to_s)
7
9
 
8
10
  @exclude_data ||= {}
9
11
  unless @exclude_data[:variants]
@@ -2,13 +2,7 @@
2
2
 
3
3
  json.cache! [I18n.locale, shipment] do
4
4
  json.(shipment, *shipment_attributes)
5
- json.selected_shipping_rate do
6
- if shipment.selected_shipping_rate
7
- json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipment.selected_shipping_rate)
8
- else
9
- json.nil!
10
- end
11
- end
5
+ json.partial!("spree/api/shipments/small", shipment: shipment)
12
6
  json.inventory_units(shipment.inventory_units) do |inventory_unit|
13
7
  json.(inventory_unit, *inventory_unit_attributes)
14
8
  json.variant do
@@ -37,9 +31,6 @@ json.cache! [I18n.locale, shipment] do
37
31
  json.ship_address do
38
32
  json.partial!("spree/api/addresses/address", address: shipment.order.shipping_address)
39
33
  end
40
- json.adjustments(shipment.order.adjustments) do |adjustment|
41
- json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment)
42
- end
43
34
  json.payments(shipment.order.payments) do |payment|
44
35
  json.(payment, :id, :amount, :display_amount, :state)
45
36
  if payment.source
@@ -1,17 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.cache! [I18n.locale, variant] do
3
+ json.cache! [I18n.locale, current_pricing_options, variant] do
4
4
  json.(variant, *variant_attributes)
5
- json.display_price(variant.display_price.to_s)
5
+ json.price(variant.price_for(current_pricing_options).try(:to_d))
6
+ json.display_price(variant.price_for(current_pricing_options).to_s)
6
7
  json.options_text(variant.options_text)
7
8
  json.track_inventory(variant.should_track_inventory?)
8
9
  json.in_stock(variant.in_stock?)
9
10
  json.is_backorderable(variant.is_backorderable?)
10
11
 
11
- # We can't represent Float::INFINITY in JSON
12
- # Under JSON this woulb be NULL
13
- # Under oj this would error
14
- json.total_on_hand(variant.should_track_inventory? ? variant.total_on_hand : nil)
12
+ json.total_on_hand(total_on_hand_for(variant))
15
13
 
16
14
  json.is_destroyed(variant.destroyed?)
17
15
  json.option_values(variant.option_values) do |option_value|
@@ -1,23 +1,26 @@
1
+ ---
1
2
  en:
2
3
  spree:
3
4
  api:
4
- must_specify_api_key: "You must specify an API key."
5
- invalid_api_key: "Invalid API key (%{key}) specified."
6
- unauthorized: "You are not authorized to perform that action."
7
- invalid_resource: "Invalid resource. Please fix errors and try again."
8
- resource_not_found: "The resource you were looking for could not be found."
9
- gateway_error: "There was a problem with the payment gateway: %{text}"
10
- delete_restriction_error: "Cannot delete record."
11
- key_generated: "Key generated"
12
- key_cleared: "Key cleared"
5
+ delete_restriction_error: Cannot delete record.
6
+ gateway_error: 'There was a problem with the payment gateway: %{text}'
7
+ invalid_api_key: Invalid API key (%{key}) specified.
8
+ invalid_resource: Invalid resource. Please fix errors and try again.
9
+ invalid_taxonomy_id: Invalid taxonomy id.
10
+ must_specify_api_key: You must specify an API key.
13
11
  order:
14
- could_not_transition: "The order could not be transitioned. Please fix the errors and try again."
15
- invalid_shipping_method: "Invalid shipping method specified."
16
- expected_total_mismatch: "Expected total does not match actual total."
17
- quantity_is_not_available: "Quantity is not available for items in your order"
12
+ could_not_transition: The order could not be transitioned. Please fix the
13
+ errors and try again.
14
+ expected_total_mismatch: Expected total does not match actual total.
15
+ invalid_shipping_method: Invalid shipping method specified.
16
+ quantity_is_not_available: Quantity is not available for items in your order
18
17
  payment:
19
- credit_over_limit: "This payment can only be credited up to %{limit}. Please specify an amount less than or equal to this number."
20
- update_forbidden: "This payment cannot be updated because it is %{state}."
18
+ credit_over_limit: This payment can only be credited up to %{limit}. Please
19
+ specify an amount less than or equal to this number.
20
+ update_forbidden: This payment cannot be updated because it is %{state}.
21
+ resource_not_found: The resource you were looking for could not be found.
21
22
  shipment:
22
- cannot_ready: "Cannot ready shipment."
23
- invalid_taxonomy_id: "Invalid taxonomy id."
23
+ cannot_ready: Cannot ready shipment.
24
+ transfer_success: Variants successfully transferred
25
+ stock_not_below_zero: Stock must not be below zero.
26
+ unauthorized: You are not authorized to perform that action.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ResizeApiKeyField < ActiveRecord::Migration[4.2]
4
- def change
4
+ def up
5
5
  unless defined?(User)
6
6
  change_column :spree_users, :api_key, :string, limit: 48
7
7
  end
@@ -54,7 +54,7 @@ module Spree
54
54
 
55
55
  before {
56
56
  user.clear_spree_api_key!
57
- Spree::Config.roles_for_auto_api_key = ['hobbit']
57
+ stub_spree_preferences roles_for_auto_api_key: ['hobbit']
58
58
  }
59
59
 
60
60
  it { expect { subject }.to change { user.reload.spree_api_key }.from(nil) }
@@ -69,7 +69,7 @@ module Spree
69
69
  before {
70
70
  user.clear_spree_api_key!
71
71
  other_user.clear_spree_api_key!
72
- Spree::Config.generate_api_key_for_all_roles = true
72
+ stub_spree_preferences(generate_api_key_for_all_roles: true)
73
73
  }
74
74
 
75
75
  it { expect { subject }.to change { user.reload.spree_api_key }.from(nil) }
@@ -89,7 +89,7 @@ module Spree
89
89
  end
90
90
 
91
91
  it "grants an api key on create when set to true" do
92
- Spree::Config.generate_api_key_for_all_roles = true
92
+ stub_spree_preferences(generate_api_key_for_all_roles: true)
93
93
 
94
94
  expect(user.spree_api_key).to eq(nil)
95
95
 
@@ -6,7 +6,7 @@ module Spree
6
6
  describe Api::CheckoutsController, type: :request do
7
7
  before(:each) do
8
8
  stub_authentication!
9
- Spree::Config[:track_inventory_levels] = false
9
+ stub_spree_preferences track_inventory_levels: false
10
10
  country_zone = create(:zone, name: 'CountryZone')
11
11
  @state = create(:state)
12
12
  @country = @state.country
@@ -17,10 +17,6 @@ module Spree
17
17
  @payment_method = create(:credit_card_payment_method)
18
18
  end
19
19
 
20
- after do
21
- Spree::Config[:track_inventory_levels] = true
22
- end
23
-
24
20
  context "PUT 'update'" do
25
21
  let(:order) do
26
22
  order = create(:order_with_line_items)
@@ -176,7 +172,6 @@ module Spree
176
172
  end
177
173
 
178
174
  describe 'setting the payment amount' do
179
- let(:order) { create(:order_with_line_items, state: :payment) }
180
175
  let(:params) do
181
176
  {
182
177
  order_token: order.guest_token,
@@ -327,44 +322,17 @@ module Spree
327
322
  end
328
323
  end
329
324
 
330
- it "cannot update attributes of another step" do
331
- order.update_column(:state, "payment")
332
-
333
- params = {
334
- order_token: order.guest_token,
335
- order: {
336
- payments_attributes: [
337
- {
338
- payment_method_id: @payment_method.id.to_s,
339
- source_attributes: attributes_for(:credit_card)
340
- }
341
- ],
342
- ship_address_attributes: {
343
- zipcode: 'MALICIOUS ZIPCODE'
344
- }
345
- }
346
- }
347
- expect do
348
- put spree.api_checkout_path(order), params: params
349
- end.not_to change { order.reload.ship_address.zipcode }
350
- expect(response.status).to eq(200)
351
- end
352
-
353
325
  it "returns the order if the order is already complete" do
354
326
  order.update_columns(completed_at: Time.current, state: 'complete')
355
327
  put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token }
356
328
  assert_unauthorized!
357
329
  end
358
330
 
359
- context "in delivery state" do
360
- let(:order) { create(:order_with_line_items, state: :delivery) }
361
-
362
- # Regression test for https://github.com/spree/spree/issues/3784
363
- it "can update the special instructions for an order" do
364
- instructions = "Don't drop it. (Please)"
365
- put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { special_instructions: instructions } }
366
- expect(json_response['special_instructions']).to eql(instructions)
367
- end
331
+ # Regression test for https://github.com/spree/spree/issues/3784
332
+ it "can update the special instructions for an order" do
333
+ instructions = "Don't drop it. (Please)"
334
+ put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { special_instructions: instructions } }
335
+ expect(json_response['special_instructions']).to eql(instructions)
368
336
  end
369
337
 
370
338
  context "as an admin" do
@@ -156,7 +156,6 @@ module Spree
156
156
  end
157
157
 
158
158
  context 'creating payment' do
159
- let!(:order) { create(:order_with_line_items) }
160
159
  let(:order_params) { super().merge(payments_attributes: [{ payment_method_id: payment_method.id }]) }
161
160
 
162
161
  context "with allowed payment method" do
@@ -167,28 +166,6 @@ module Spree
167
166
  subject
168
167
  }.to change { Spree::Payment.count }.by(1)
169
168
  end
170
-
171
- context 'trying to change the address' do
172
- let(:order_params) do
173
- super().merge(
174
- ship_address_attributes: {
175
- zipcode: '90100'
176
- }
177
- )
178
- end
179
-
180
- it 'changes the address' do
181
- expect {
182
- subject
183
- }.to change { order.reload.ship_address.zipcode }
184
- end
185
-
186
- it 'invalidates the shipments' do
187
- expect {
188
- subject
189
- }.to change { order.reload.shipments }.to([])
190
- end
191
- end
192
169
  end
193
170
 
194
171
  context "with disallowed payment method" do
@@ -384,7 +361,7 @@ module Spree
384
361
 
385
362
  it 'renders the payment source view for store credit' do
386
363
  subject
387
- expect(response).to render_template partial: 'spree/api/payments/source_views/_storecredit'
364
+ expect(response).to render_template partial: 'spree/api/payments/source_views/_store_credit'
388
365
  end
389
366
  end
390
367
  end
@@ -838,6 +815,43 @@ module Spree
838
815
  expect(response.status).to eq 201
839
816
  expect(json_response["user_id"]).to eq(user.id)
840
817
  end
818
+
819
+ context "with payment" do
820
+ let(:params) do
821
+ {
822
+ payments: [{
823
+ amount: '10.0',
824
+ payment_method: create(:payment_method).name,
825
+ source: {
826
+ month: "01",
827
+ year: Date.today.year.to_s.last(2),
828
+ cc_type: "123",
829
+ last_digits: "1111",
830
+ name: "Credit Card"
831
+ }
832
+ }]
833
+ }
834
+ end
835
+
836
+ context "with source" do
837
+ it "creates a payment" do
838
+ post spree.api_orders_path, params: { order: params }
839
+ payment = json_response['payments'].first
840
+
841
+ expect(response.status).to eq 201
842
+ expect(payment['amount']).to eql "10.0"
843
+ expect(payment['source']['last_digits']).to eql "1111"
844
+ end
845
+
846
+ context "when payment_method is missing" do
847
+ it "returns an error" do
848
+ params[:payments][0].delete(:payment_method)
849
+ post spree.api_orders_path, params: { order: params }
850
+ expect(response.status).to eq 404
851
+ end
852
+ end
853
+ end
854
+ end
841
855
  end
842
856
 
843
857
  context "updating" do
@@ -851,7 +865,7 @@ module Spree
851
865
 
852
866
  context "can cancel an order" do
853
867
  before do
854
- Spree::Config[:mails_from] = "spree@example.com"
868
+ stub_spree_preferences(mails_from: "spree@example.com")
855
869
 
856
870
  order.completed_at = Time.current
857
871
  order.state = 'complete'
@@ -158,15 +158,13 @@ module Spree
158
158
  end
159
159
 
160
160
  context "tracking is disabled" do
161
- before { Config.track_inventory_levels = false }
161
+ before { stub_spree_preferences(track_inventory_levels: false) }
162
162
 
163
163
  it "still displays valid json with total_on_hand Float::INFINITY" do
164
164
  get spree.api_product_path(product)
165
165
  expect(response).to be_ok
166
166
  expect(json_response[:total_on_hand]).to eq nil
167
167
  end
168
-
169
- after { Config.track_inventory_levels = true }
170
168
  end
171
169
 
172
170
  context "finds a product by slug first then by id" do
@@ -295,6 +293,23 @@ module Spree
295
293
  expect(json_response['shipping_category_id']).to eq shipping_id
296
294
  end
297
295
 
296
+ context "when tracking is disabled" do
297
+ before { stub_spree_preferences(track_inventory_levels: false) }
298
+
299
+ it "still displays valid json with total_on_hand Float::INFINITY" do
300
+ post spree.api_products_path, params: {
301
+ product: {
302
+ name: "The Other Product",
303
+ price: 19.99,
304
+ shipping_category_id: create(:shipping_category).id
305
+ }
306
+ }
307
+
308
+ expect(response.status).to eq(201)
309
+ expect(json_response['total_on_hand']).to eq nil
310
+ end
311
+ end
312
+
298
313
  it "puts the created product in the given taxon" do
299
314
  product_data[:taxon_ids] = taxon_1.id.to_s
300
315
  post spree.api_products_path, params: { product: product_data }
@@ -17,13 +17,21 @@ module Spree
17
17
  it "can create a new return authorization" do
18
18
  stock_location = FactoryBot.create(:stock_location)
19
19
  reason = FactoryBot.create(:return_reason)
20
+ reimbursement = FactoryBot.create(:reimbursement_type)
21
+ unit = FactoryBot.create(:inventory_unit)
20
22
  rma_params = { stock_location_id: stock_location.id,
21
23
  return_reason_id: reason.id,
24
+ return_items_attributes: [{
25
+ inventory_unit_id: unit.id,
26
+ preferred_reimbursement_type_id: reimbursement.id,
27
+ }],
22
28
  memo: "Defective" }
23
29
  post spree.api_order_return_authorizations_path(order), params: { order_id: order.number, return_authorization: rma_params }
24
30
  expect(response.status).to eq(201)
25
31
  expect(json_response).to have_attributes(attributes)
26
32
  expect(json_response["state"]).not_to be_blank
33
+ return_authorization = Spree::ReturnAuthorization.last
34
+ expect(return_authorization.return_items.first.preferred_reimbursement_type).to eql reimbursement
27
35
  end
28
36
  end
29
37
 
@@ -170,7 +170,7 @@ module Spree
170
170
  it "does not allow negative inventory for the stock item" do
171
171
  subject
172
172
  expect(response.status).to eq 422
173
- expect(response.body).to match I18n.t('spree.stock_not_below_zero')
173
+ expect(response.body).to match I18n.t('spree.api.stock_not_below_zero')
174
174
  expect(assigns(:stock_item).count_on_hand).to eq 0
175
175
  end
176
176
  end
@@ -236,7 +236,7 @@ module Spree
236
236
  it "does not allow negative inventory for the stock item" do
237
237
  subject
238
238
  expect(response.status).to eq 422
239
- expect(response.body).to match I18n.t('spree.stock_not_below_zero')
239
+ expect(response.body).to match I18n.t('spree.api.stock_not_below_zero')
240
240
  expect(assigns(:stock_item).count_on_hand).to eq 10
241
241
  end
242
242
  end
@@ -294,7 +294,7 @@ module Spree
294
294
  it "does not allow negative inventory for the stock item" do
295
295
  subject
296
296
  expect(response.status).to eq 422
297
- expect(response.body).to match I18n.t('spree.stock_not_below_zero')
297
+ expect(response.body).to match I18n.t('spree.api.stock_not_below_zero')
298
298
  expect(assigns(:stock_item).count_on_hand).to eq 10
299
299
  end
300
300
  end
@@ -248,6 +248,18 @@ module Spree
248
248
  expect(json_response["variant_properties"].first).to have_attributes(expected_attrs)
249
249
  end
250
250
  end
251
+
252
+ context "when tracking is disabled" do
253
+ before do
254
+ stub_spree_preferences(track_inventory_levels: false)
255
+ subject
256
+ end
257
+
258
+ it "still displays valid json with total_on_hand Float::INFINITY" do
259
+ expect(response.status).to eq(200)
260
+ expect(json_response['total_on_hand']).to eq nil
261
+ end
262
+ end
251
263
  end
252
264
 
253
265
  it "can learn how to create a new variant" do
data/spec/spec_helper.rb CHANGED
@@ -59,7 +59,6 @@ RSpec.configure do |config|
59
59
 
60
60
  config.before(:each) do
61
61
  Rails.cache.clear
62
- reset_spree_preferences
63
62
  Spree::Api::Config[:requires_authentication] = true
64
63
  end
65
64
 
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.8.6
4
+ version: 2.9.0.rc.1
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-07-16 00:00:00.000000000 Z
11
+ date: 2019-07-01 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.8.6
61
+ version: 2.9.0.rc.1
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.8.6
68
+ version: 2.9.0.rc.1
69
69
  description: REST API for the Solidus e-commerce framework.
70
70
  email: contact@solidus.io
71
71
  executables: []
@@ -159,7 +159,7 @@ files:
159
159
  - app/views/spree/api/payments/show.json.jbuilder
160
160
  - app/views/spree/api/payments/source_views/_check.json.jbuilder
161
161
  - app/views/spree/api/payments/source_views/_gateway.json.jbuilder
162
- - app/views/spree/api/payments/source_views/_storecredit.json.jbuilder
162
+ - app/views/spree/api/payments/source_views/_store_credit.json.jbuilder
163
163
  - app/views/spree/api/payments/update_forbidden.json.jbuilder
164
164
  - app/views/spree/api/product_properties/index.json.jbuilder
165
165
  - app/views/spree/api/product_properties/new.json.jbuilder
@@ -309,7 +309,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
309
  - !ruby/object:Gem::Version
310
310
  version: 1.8.23
311
311
  requirements: []
312
- rubygems_version: 3.0.3
312
+ rubyforge_project:
313
+ rubygems_version: 2.7.3
313
314
  signing_key:
314
315
  specification_version: 4
315
316
  summary: REST API for the Solidus e-commerce framework.