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.

Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -5
  3. data/Rakefile +7 -8
  4. data/app/controllers/spree/api/line_items_controller.rb +1 -3
  5. data/app/controllers/spree/api/orders_controller.rb +1 -1
  6. data/app/controllers/spree/api/products_controller.rb +1 -1
  7. data/app/controllers/spree/api/shipments_controller.rb +21 -7
  8. data/app/controllers/spree/api/stock_items_controller.rb +4 -4
  9. data/app/controllers/spree/api/taxonomies_controller.rb +1 -0
  10. data/app/controllers/spree/api/taxons_controller.rb +1 -0
  11. data/app/controllers/spree/api/variants_controller.rb +13 -4
  12. data/app/helpers/spree/api/api_helpers.rb +0 -9
  13. data/app/views/spree/api/shared/_pagination.json.jbuilder +1 -1
  14. data/app/views/spree/api/shipments/estimated_rates.json.jbuilder +4 -0
  15. data/app/views/spree/api/variants/_big.json.jbuilder +0 -1
  16. data/app/views/spree/api/variants/_small.json.jbuilder +6 -1
  17. data/config/locales/en.yml +0 -6
  18. data/config/routes.rb +3 -7
  19. data/lib/spree/api/engine.rb +0 -10
  20. data/lib/spree_api.rb +0 -1
  21. data/solidus_api.gemspec +1 -2
  22. data/spec/controllers/spree/api/resource_controller_spec.rb +9 -9
  23. data/spec/features/checkout_spec.rb +8 -8
  24. data/spec/requests/api/address_books_spec.rb +1 -3
  25. data/spec/requests/spree/api/checkouts_controller_spec.rb +4 -5
  26. data/spec/requests/spree/api/config_controller_spec.rb +2 -2
  27. data/spec/requests/spree/api/orders_controller_spec.rb +27 -11
  28. data/spec/requests/spree/api/products_controller_spec.rb +1 -1
  29. data/spec/requests/spree/api/return_authorizations_controller_spec.rb +13 -13
  30. data/spec/requests/spree/api/shipments_controller_spec.rb +66 -4
  31. data/spec/requests/spree/api/stock_items_controller_spec.rb +4 -4
  32. data/spec/requests/spree/api/stock_locations_controller_spec.rb +7 -7
  33. data/spec/requests/spree/api/taxonomies_controller_spec.rb +1 -0
  34. data/spec/requests/spree/api/taxons_controller_spec.rb +3 -2
  35. data/spec/requests/spree/api/variants_controller_spec.rb +26 -0
  36. data/spec/spec_helper.rb +13 -23
  37. metadata +11 -41
  38. data/Gemfile +0 -5
  39. data/app/controllers/spree/api/stock_transfers_controller.rb +0 -20
  40. data/app/controllers/spree/api/transfer_items_controller.rb +0 -42
  41. data/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder +0 -1
  42. data/app/views/spree/api/stock_transfers/receive.json.jbuilder +0 -4
  43. data/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder +0 -5
  44. data/app/views/spree/api/transfer_items/show.json.jbuilder +0 -1
  45. data/spec/requests/spree/api/stock_transfers_controller_spec.rb +0 -97
  46. data/spec/requests/spree/api/transfer_items_controller_spec.rb +0 -150
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e1607236a51ff9585fc6da7df65ee8f1230e4d7c
4
- data.tar.gz: 2915ff0611fa3783baff26cc541e955abd4fc9cc
2
+ SHA256:
3
+ metadata.gz: 0f786be0873e048ce3be477e79b3e77fea2edc7b831abddcff8910b353ec8180
4
+ data.tar.gz: 78a37e6abfb77386b5fac0c0465c590337bb23d6ba930fc146583e8bad473195
5
5
  SHA512:
6
- metadata.gz: 249fb7e605274bd293e05a2614f5f3a7722a8f44f4c023a1bee1bd18460afaba31f0c88f5756b67eba44136db1cefc6161695726686b19eb50fd5dedd666693a
7
- data.tar.gz: c190543d4c098ef28c8993521e7f0cd3dcd85eba925504326ae2a37dfeb9a3c1b22c3c4b2b69d4673e414b3c8a72b304bd298c414dcb37a75284a9333ee35928
6
+ metadata.gz: 6ba8a8df12bdb893791882ab855ca8912163ce0c9bf750effe7d1b46ab6ff1b0bff0ee64f787fa317c9047db2db89f4d92fa3ef6c403f4c1e1bb989123770d0c
7
+ data.tar.gz: 6c2f3890c3dfa009f3d1607b648d3109b26be3a52209a492b7162ca985633e79ff6ad0b3189c72dbcbf3d5ae62cfefcfabfddfb15b39235a637fca596eb7b765
data/README.md CHANGED
@@ -4,10 +4,6 @@ API contains controllers and rabl views implementing the REST API of solidus.
4
4
 
5
5
  ## Testing
6
6
 
7
- Create the test site
8
-
9
- bundle exec rake test_app
10
-
11
7
  Run the tests
12
8
 
13
- bundle exec rake spec
9
+ bundle exec rspec
data/Rakefile CHANGED
@@ -2,15 +2,14 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
4
  require 'rspec/core/rake_task'
5
- require 'spree/testing_support/common_rake'
6
- require 'rails/all'
5
+ require 'spree/testing_support/dummy_app/rake_tasks'
7
6
 
8
7
  RSpec::Core::RakeTask.new
9
-
10
8
  task default: :spec
11
9
 
12
- desc "Generates a dummy app for testing"
13
- task :test_app do
14
- ENV['LIB_NAME'] = 'spree/api'
15
- Rake::Task['common:test_app'].invoke
16
- end
10
+ DummyApp::RakeTasks.new(
11
+ gem_root: File.expand_path('../', __FILE__),
12
+ lib_name: 'solidus_api'
13
+ )
14
+
15
+ task test_app: 'db:reset'
@@ -12,9 +12,7 @@ module Spree
12
12
  @line_item = @order.contents.add(
13
13
  variant,
14
14
  params[:line_item][:quantity] || 1,
15
- {
16
- stock_location_quantities: params[:line_item][:stock_location_quantities]
17
- }.merge({ options: line_item_params[:options].to_h })
15
+ options: line_item_params[:options].to_h
18
16
  )
19
17
 
20
18
  if @line_item.errors.empty?
@@ -10,7 +10,7 @@ module Spree
10
10
  skip_before_action :authenticate_user, only: :apply_coupon_code
11
11
 
12
12
  before_action :find_order, except: [:create, :mine, :current, :index]
13
- around_action :lock_order, except: [:create, :mine, :current, :index]
13
+ around_action :lock_order, except: [:create, :mine, :current, :index, :show]
14
14
 
15
15
  # Dynamically defines our stores checkout steps to ensure we check authorization on each step.
16
16
  Spree::Order.checkout_steps.keys.each do |step|
@@ -91,7 +91,7 @@ module Spree
91
91
  def destroy
92
92
  @product = find_product(params[:id])
93
93
  authorize! :destroy, @product
94
- @product.destroy
94
+ @product.discard
95
95
  respond_with(@product, status: 204)
96
96
  end
97
97
 
@@ -2,9 +2,9 @@ module Spree
2
2
  module Api
3
3
  class ShipmentsController < Spree::Api::BaseController
4
4
  before_action :find_order_on_create, only: :create
5
- before_action :find_shipment, only: [:update, :ship, :ready, :add, :remove]
5
+ before_action :find_shipment, only: [:update, :ship, :ready, :add, :remove, :estimated_rates, :select_shipping_method]
6
6
  before_action :load_transfer_params, only: [:transfer_to_location, :transfer_to_shipment]
7
- around_action :lock_order, except: [:mine]
7
+ around_action :lock_order, except: [:mine, :estimated_rates]
8
8
  before_action :update_shipment, only: [:ship, :ready, :add, :remove]
9
9
 
10
10
  def mine
@@ -22,6 +22,20 @@ module Spree
22
22
  end
23
23
  end
24
24
 
25
+ def estimated_rates
26
+ authorize! :update, @shipment
27
+ estimator = Spree::Config.stock.estimator_class.new
28
+ @shipping_rates = estimator.shipping_rates(@shipment.to_package, false)
29
+ end
30
+
31
+ def select_shipping_method
32
+ authorize! :update, @shipment
33
+ shipping_method = Spree::ShippingMethod.find(params.require(:shipping_method_id))
34
+ @shipment.select_shipping_method(shipping_method)
35
+ @order.recalculate
36
+ respond_with(@shipment, default_template: :show)
37
+ end
38
+
25
39
  def create
26
40
  authorize! :create, Shipment
27
41
  quantity = params[:quantity].to_i
@@ -70,13 +84,13 @@ module Spree
70
84
  def remove
71
85
  quantity = params[:quantity].to_i
72
86
 
73
- if @shipment.pending?
87
+ if @shipment.shipped? || @shipment.canceled?
88
+ @shipment.errors.add(:base, :cannot_remove_items_shipment_state, state: @shipment.state)
89
+ invalid_resource!(@shipment)
90
+ else
74
91
  @shipment.order.contents.remove(variant, quantity, { shipment: @shipment })
75
92
  @shipment.reload if @shipment.persisted?
76
93
  respond_with(@shipment, default_template: :show)
77
- else
78
- @shipment.errors.add(:base, :cannot_remove_items_shipment_state, state: @shipment.state)
79
- invalid_resource!(@shipment)
80
94
  end
81
95
  end
82
96
 
@@ -97,7 +111,7 @@ module Spree
97
111
  )
98
112
 
99
113
  if fulfilment_changer.run!
100
- render json: { success: true, message: Spree.t(:shipment_transfer_success) }, status: :accepted
114
+ render json: { success: true, message: t('spree.shipment_transfer_success') }, status: :accepted
101
115
  else
102
116
  render json: { success: false, message: fulfilment_changer.errors.full_messages.to_sentence }, status: :accepted
103
117
  end
@@ -3,7 +3,7 @@ module Spree
3
3
  class StockItemsController < Spree::Api::BaseController
4
4
  before_action :load_stock_location, only: [:index, :show, :create]
5
5
 
6
- rescue_from StockLocation::InvalidMovementError, with: :render_stock_items_error
6
+ rescue_from Spree::StockLocation::InvalidMovementError, with: :render_stock_items_error
7
7
 
8
8
  def index
9
9
  @stock_items = paginate(scope.ransack(params[:q]).result)
@@ -49,7 +49,7 @@ module Spree
49
49
 
50
50
  def destroy
51
51
  @stock_item = Spree::StockItem.accessible_by(current_ability, :destroy).find(params[:id])
52
- @stock_item.destroy
52
+ @stock_item.discard
53
53
  respond_with(@stock_item, status: 204)
54
54
  end
55
55
 
@@ -75,14 +75,14 @@ module Spree
75
75
 
76
76
  def adjust_stock_item_count_on_hand(count_on_hand_adjustment)
77
77
  if @stock_item.count_on_hand + count_on_hand_adjustment < 0
78
- raise StockLocation::InvalidMovementError.new(Spree.t(:stock_not_below_zero))
78
+ raise StockLocation::InvalidMovementError.new(t('spree.stock_not_below_zero'))
79
79
  end
80
80
  @stock_movement = @stock_location.move(@stock_item.variant, count_on_hand_adjustment, current_api_user)
81
81
  @stock_item = @stock_movement.stock_item
82
82
  end
83
83
 
84
84
  def render_stock_items_error
85
- render json: { error: Spree.t(:stock_not_below_zero) }, status: 422
85
+ render json: { error: t('spree.stock_not_below_zero') }, status: 422
86
86
  end
87
87
  end
88
88
  end
@@ -15,6 +15,7 @@ module Spree
15
15
 
16
16
  # Because JSTree wants parameters in a *slightly* different format
17
17
  def jstree
18
+ Spree::Deprecation.warn("Please don't use `/api/taxonomies/:taxonomy_id/jstree` endpoint. It is deprecated and will be removed in the next future.", caller)
18
19
  show
19
20
  end
20
21
 
@@ -23,6 +23,7 @@ module Spree
23
23
  end
24
24
 
25
25
  def jstree
26
+ Spree::Deprecation.warn("Please don't use `/api/taxonomies/:taxonomy_id/taxons/:taxon_id/jstree` endpoint. It is deprecated and will be removed in the next future.", caller)
26
27
  show
27
28
  end
28
29
 
@@ -15,7 +15,7 @@ module Spree
15
15
 
16
16
  def destroy
17
17
  @variant = scope.accessible_by(current_ability, :destroy).find(params[:id])
18
- @variant.destroy
18
+ @variant.discard
19
19
  respond_with(@variant, status: 204)
20
20
  end
21
21
 
@@ -23,7 +23,7 @@ module Spree
23
23
  # we render on the view so we better update it any time a node is included
24
24
  # or removed from the views.
25
25
  def index
26
- @variants = scope.includes({ option_values: :option_type }, :product, :default_price, :images, { stock_items: :stock_location })
26
+ @variants = scope.includes(include_list)
27
27
  .ransack(params[:q]).result
28
28
 
29
29
  @variants = paginate(@variants)
@@ -34,7 +34,7 @@ module Spree
34
34
  end
35
35
 
36
36
  def show
37
- @variant = scope.includes({ option_values: :option_type }, :option_values, :product, :default_price, :images, { stock_items: :stock_location })
37
+ @variant = scope.includes(include_list)
38
38
  .find(params[:id])
39
39
  respond_with(@variant)
40
40
  end
@@ -66,14 +66,23 @@ module Spree
66
66
  end
67
67
 
68
68
  in_stock_only = ActiveRecord::Type::Boolean.new.cast(params[:in_stock_only])
69
+ suppliable_only = ActiveRecord::Type::Boolean.new.cast(params[:suppliable_only])
69
70
  variants = variants.accessible_by(current_ability, :read)
70
- variants = variants.in_stock if in_stock_only || cannot?(:view_out_of_stock, Spree::Variant)
71
+ if in_stock_only || cannot?(:view_out_of_stock, Spree::Variant)
72
+ variants = variants.in_stock
73
+ elsif suppliable_only
74
+ variants = variants.suppliable
75
+ end
71
76
  variants
72
77
  end
73
78
 
74
79
  def variant_params
75
80
  params.require(:variant).permit(permitted_variant_attributes)
76
81
  end
82
+
83
+ def include_list
84
+ [{ option_values: :option_type }, :product, :default_price, :images, { stock_items: :stock_location }]
85
+ end
77
86
  end
78
87
  end
79
88
  end
@@ -31,9 +31,6 @@ module Spree
31
31
  :promotion_attributes,
32
32
  :store_attributes,
33
33
  :store_credit_history_attributes,
34
- :stock_transfer_attributes,
35
- :transfer_item_attributes,
36
- :transfer_item_variant_attributes,
37
34
  :variant_property_attributes
38
35
  ]
39
36
 
@@ -177,12 +174,6 @@ module Spree
177
174
  :display_event_date
178
175
  ]
179
176
 
180
- @@stock_transfer_attributes = [:id, :number]
181
-
182
- @@transfer_item_attributes = [:id, :expected_quantity, :received_quantity]
183
-
184
- @@transfer_item_variant_attributes = []
185
-
186
177
  def variant_attributes
187
178
  if @current_user_roles && @current_user_roles.include?("admin")
188
179
  @@variant_attributes + [:cost_price]
@@ -2,4 +2,4 @@ json.count pagination.count
2
2
  json.total_count pagination.total_count
3
3
  json.current_page pagination.current_page
4
4
  json.pages pagination.total_pages
5
- json.per_page pagination.limit_value
5
+ json.per_page pagination.current_per_page
@@ -0,0 +1,4 @@
1
+ json.shipping_rates @shipping_rates do |shipping_rate|
2
+ json.(shipping_rate, :name, :cost, :shipping_method_id, :shipping_method_code)
3
+ json.display_cost(shipping_rate.display_cost.to_s)
4
+ end
@@ -1,7 +1,6 @@
1
1
  json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
2
2
  json.(variant, *variant_attributes)
3
3
  json.partial!("spree/api/variants/small", variant: variant)
4
- json.total_on_hand(variant.total_on_hand)
5
4
  json.variant_properties(variant.variant_properties) do |variant_property|
6
5
  json.(variant_property, *variant_property_attributes)
7
6
  end
@@ -5,7 +5,12 @@ json.cache! [I18n.locale, variant] do
5
5
  json.track_inventory(variant.should_track_inventory?)
6
6
  json.in_stock(variant.in_stock?)
7
7
  json.is_backorderable(variant.is_backorderable?)
8
- json.total_on_hand(variant.total_on_hand)
8
+
9
+ # We can't represent Float::INFINITY in JSON
10
+ # Under JSON this woulb be NULL
11
+ # Under oj this would error
12
+ json.total_on_hand(variant.should_track_inventory? ? variant.total_on_hand : nil)
13
+
9
14
  json.is_destroyed(variant.destroyed?)
10
15
  json.option_values(variant.option_values) do |option_value|
11
16
  json.(option_value, *option_value_attributes)
@@ -8,12 +8,6 @@ en:
8
8
  resource_not_found: "The resource you were looking for could not be found."
9
9
  gateway_error: "There was a problem with the payment gateway: %{text}"
10
10
  delete_restriction_error: "Cannot delete record."
11
- access: "API Access"
12
- key: "Key"
13
- clear_key: "Clear key"
14
- regenerate_key: "Regenerate Key"
15
- no_key: "No key"
16
- generate_key: "Generate API key"
17
11
  key_generated: "Key generated"
18
12
  key_cleared: "Key cleared"
19
13
  order:
data/config/routes.rb CHANGED
@@ -82,6 +82,9 @@ Spree::Core::Engine.routes.draw do
82
82
  end
83
83
 
84
84
  member do
85
+ get :estimated_rates
86
+ put :select_shipping_method
87
+
85
88
  put :ready
86
89
  put :ship
87
90
  put :add
@@ -120,13 +123,6 @@ Spree::Core::Engine.routes.draw do
120
123
 
121
124
  resources :stock_items, only: [:index, :update, :destroy]
122
125
 
123
- resources :stock_transfers, only: [] do
124
- member do
125
- post :receive
126
- end
127
- resources :transfer_items, only: [:create, :update, :destroy]
128
- end
129
-
130
126
  resources :stores
131
127
 
132
128
  resources :store_credit_events, only: [] do
@@ -9,16 +9,6 @@ module Spree
9
9
  initializer "spree.api.environment", before: :load_config_initializers do |_app|
10
10
  Spree::Api::Config = Spree::ApiConfiguration.new
11
11
  end
12
-
13
- initializer "spree.api.versioncake" do |_app|
14
- VersionCake.setup do |config|
15
- config.resources do |r|
16
- r.resource %r{.*}, [], [], [1]
17
- end
18
- config.missing_version = 1
19
- config.extraction_strategy = :http_header
20
- end
21
- end
22
12
  end
23
13
  end
24
14
  end
data/lib/spree_api.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  require 'spree/api'
2
2
  require 'spree/api/responders'
3
- require 'versioncake'
4
3
  require 'jbuilder'
data/solidus_api.gemspec CHANGED
@@ -21,8 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.required_rubygems_version = '>= 1.8.23'
22
22
 
23
23
  gem.add_dependency 'solidus_core', gem.version
24
- gem.add_dependency 'versioncake', '~> 3.0'
25
24
  gem.add_dependency 'responders'
26
25
  gem.add_dependency 'jbuilder', '~> 2.6'
27
- gem.add_dependency 'kaminari', '>= 0.17', '< 2.0'
26
+ gem.add_dependency 'kaminari-activerecord', '~> 1.1'
28
27
  end
@@ -51,14 +51,14 @@ module Spree
51
51
 
52
52
  it "returns no widgets" do
53
53
  get :index, params: { token: user.spree_api_key }, as: :json
54
- expect(response).to be_success
54
+ expect(response).to be_successful
55
55
  expect(json_response['widgets']).to be_blank
56
56
  end
57
57
 
58
58
  context "it has authorization to read widgets" do
59
59
  it "returns widgets" do
60
60
  get :index, params: { token: admin_user.spree_api_key }, as: :json
61
- expect(response).to be_success
61
+ expect(response).to be_successful
62
62
  expect(json_response['widgets']).to include(hash_including(
63
63
  'name' => 'a widget',
64
64
  'position' => 1
@@ -70,26 +70,26 @@ module Spree
70
70
 
71
71
  it "returns both widgets from comma separated string" do
72
72
  get :index, params: { ids: [widget.id, widget2.id].join(','), token: admin_user.spree_api_key }, as: :json
73
- expect(response).to be_success
73
+ expect(response).to be_successful
74
74
  expect(json_response['widgets'].size).to eq 2
75
75
  end
76
76
 
77
77
  it "returns both widgets from multiple arguments" do
78
78
  get :index, params: { ids: [widget.id, widget2.id], token: admin_user.spree_api_key }, as: :json
79
- expect(response).to be_success
79
+ expect(response).to be_successful
80
80
  expect(json_response['widgets'].size).to eq 2
81
81
  end
82
82
 
83
83
  it "returns one requested widgets" do
84
84
  get :index, params: { ids: widget2.id.to_s, token: admin_user.spree_api_key }, as: :json
85
- expect(response).to be_success
85
+ expect(response).to be_successful
86
86
  expect(json_response['widgets'].size).to eq 1
87
87
  expect(json_response['widgets'][0]['id']).to eq widget2.id
88
88
  end
89
89
 
90
90
  it "returns no widgets if empty" do
91
91
  get :index, params: { ids: '', token: admin_user.spree_api_key }, as: :json
92
- expect(response).to be_success
92
+ expect(response).to be_successful
93
93
  expect(json_response['widgets']).to be_empty
94
94
  end
95
95
  end
@@ -107,7 +107,7 @@ module Spree
107
107
  context "it has authorization read widgets" do
108
108
  it "returns widget details" do
109
109
  get :show, params: { id: widget.to_param, token: admin_user.spree_api_key }, as: :json
110
- expect(response).to be_success
110
+ expect(response).to be_successful
111
111
  expect(json_response['name']).to eq 'a widget'
112
112
  end
113
113
  end
@@ -122,7 +122,7 @@ module Spree
122
122
  context "it is allowed to view a new widget" do
123
123
  it "can learn how to create a new widget" do
124
124
  get :new, params: { token: admin_user.spree_api_key }, as: :json
125
- expect(response).to be_success
125
+ expect(response).to be_successful
126
126
  expect(json_response["attributes"]).to eq(['name'])
127
127
  end
128
128
  end
@@ -159,7 +159,7 @@ module Spree
159
159
  context "it is authorized to update widgets" do
160
160
  it "can update a widget" do
161
161
  put :update, params: { id: widget.to_param, widget: { name: "another widget" }, token: admin_user.spree_api_key }, as: :json
162
- expect(response).to be_success
162
+ expect(response).to be_successful
163
163
  expect(json_response['name']).to eq 'another widget'
164
164
  expect(widget.reload.name).to eq 'another widget'
165
165
  end
@@ -3,16 +3,16 @@ require 'spec_helper'
3
3
  module Spree
4
4
  describe 'Api Feature Specs', type: :request do
5
5
  before { Spree::Api::Config[:requires_authentication] = false }
6
- let!(:promotion) { FactoryGirl.create(:promotion, :with_order_adjustment, code: 'foo', weighted_order_adjustment_amount: 10) }
6
+ let!(:promotion) { FactoryBot.create(:promotion, :with_order_adjustment, code: 'foo', weighted_order_adjustment_amount: 10) }
7
7
  let(:promotion_code) { promotion.codes.first }
8
- let!(:store) { FactoryGirl.create(:store) }
9
- let(:bill_address) { FactoryGirl.create(:address) }
10
- let(:ship_address) { FactoryGirl.create(:address) }
11
- let(:variant_1) { FactoryGirl.create(:variant, price: 100.00) }
12
- let(:variant_2) { FactoryGirl.create(:variant, price: 200.00) }
13
- let(:payment_method) { FactoryGirl.create(:check_payment_method) }
8
+ let!(:store) { FactoryBot.create(:store) }
9
+ let(:bill_address) { FactoryBot.create(:address) }
10
+ let(:ship_address) { FactoryBot.create(:address) }
11
+ let(:variant_1) { FactoryBot.create(:variant, price: 100.00) }
12
+ let(:variant_2) { FactoryBot.create(:variant, price: 200.00) }
13
+ let(:payment_method) { FactoryBot.create(:check_payment_method) }
14
14
  let!(:shipping_method) do
15
- FactoryGirl.create(:shipping_method).tap do |shipping_method|
15
+ FactoryBot.create(:shipping_method).tap do |shipping_method|
16
16
  shipping_method.zones.first.zone_members.create!(zoneable: ship_address.country)
17
17
  shipping_method.calculator.set_preference(:amount, 10.0)
18
18
  end
@@ -119,9 +119,7 @@ module Spree
119
119
  context 'on behalf of address book owner' do
120
120
  context 'with ability' do
121
121
  before do
122
- Spree::RoleConfiguration.configure do |config|
123
- config.assign_permissions 'Prefect', [Spree::PermissionSets::UserManagement]
124
- end
122
+ Spree::Config.roles.assign_permissions 'Prefect', [Spree::PermissionSets::UserManagement]
125
123
  create(:user, spree_api_key: 'galleon', spree_roles: [build(:role, name: 'Prefect')])
126
124
  end
127
125
 
@@ -103,7 +103,7 @@ module Spree
103
103
 
104
104
  # Regression Spec for https://github.com/spree/spree/issues/5389 and https://github.com/spree/spree/issues/5880
105
105
  it "can update addresses but not transition to delivery w/o shipping setup" do
106
- Spree::ShippingMethod.destroy_all
106
+ Spree::ShippingMethod.all.each(&:really_destroy!)
107
107
  put spree.api_checkout_path(order),
108
108
  params: { order_token: order.guest_token, order: {
109
109
  bill_address_attributes: address,
@@ -166,7 +166,6 @@ module Spree
166
166
  end
167
167
  end
168
168
 
169
-
170
169
  it "returns errors when source is required and missing" do
171
170
  order.update_column(:state, "payment")
172
171
  put spree.api_checkout_path(order.to_param), params: { order_token: order.guest_token, order: { payments_attributes: [{ payment_method_id: @payment_method.id }] } }
@@ -380,7 +379,7 @@ module Spree
380
379
  order.update_column(:email, "spree@example.com")
381
380
  put spree.next_api_checkout_path(order), params: { order_token: order.guest_token }
382
381
  expect(response.status).to eq(422)
383
- expect(json_response["errors"]["base"]).to include(Spree.t(:there_are_no_items_for_this_order))
382
+ expect(json_response["errors"]["base"]).to include(I18n.t('spree.there_are_no_items_for_this_order'))
384
383
  end
385
384
 
386
385
  it "can transition an order to the next state" do
@@ -426,7 +425,7 @@ module Spree
426
425
  it "returns a sensible error when no payment method is specified" do
427
426
  # put :complete, id: order.to_param, order_token: order.token, order: {}
428
427
  subject
429
- expect(json_response["errors"]["base"]).to include(Spree.t(:no_payment_found))
428
+ expect(json_response["errors"]["base"]).to include(I18n.t('spree.no_payment_found'))
430
429
  end
431
430
 
432
431
  context "with mismatched expected_total" do
@@ -436,7 +435,7 @@ module Spree
436
435
  # put :complete, id: order.to_param, order_token: order.token, expected_total: order.total + 1
437
436
  subject
438
437
  expect(response.status).to eq(400)
439
- expect(json_response['errors']['expected_total']).to include(Spree.t(:expected_total_mismatch, scope: 'api.order'))
438
+ expect(json_response['errors']['expected_total']).to include(I18n.t('spree.api.order.expected_total_mismatch'))
440
439
  end
441
440
  end
442
441
  end
@@ -10,13 +10,13 @@ module Spree
10
10
 
11
11
  it "returns Spree::Money settings" do
12
12
  get '/api/config/money'
13
- expect(response).to be_success
13
+ expect(response).to be_successful
14
14
  expect(json_response["symbol"]).to eq("$")
15
15
  end
16
16
 
17
17
  it "returns some configuration settings" do
18
18
  get '/api/config'
19
- expect(response).to be_success
19
+ expect(response).to be_successful
20
20
  expect(json_response["default_country_iso"]).to eq("US")
21
21
  expect(json_response["default_country_id"]).to eq(default_country.id)
22
22
  end