Skip to content

Commit

Permalink
Merge pull request #3818 from nebulab/kennyadsl/remove-all-deprecations
Browse files Browse the repository at this point in the history
Remove all code deprecated in Solidus v2.x
  • Loading branch information
kennyadsl authored Jan 29, 2021
2 parents 5bad6c6 + 5e3b610 commit dc813e6
Show file tree
Hide file tree
Showing 212 changed files with 140 additions and 5,753 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"Sortable": "readonly",
"Spree": "readonly",
"Turbolinks": "readonly",
"update_state": "writable",
"Proxy": "readonly"
"update_state": "writable"
}
}
6 changes: 0 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,3 @@ namespace :gem do
end
end
end

desc "Creates a sandbox application for simulating the Solidus code in a deployed Rails app"
task :sandbox do
warn "Using `rake sandbox` is deprecated, please use bin/sandbox directly instead."
sh("bin/sandbox")
end
13 changes: 1 addition & 12 deletions api/app/controllers/spree/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def invalid_resource!(resource)
end

def api_key
bearer_token || spree_token || params[:token]
bearer_token || params[:token]
end
helper_method :api_key

Expand All @@ -113,17 +113,6 @@ def bearer_token
header.gsub(pattern, '') if header.present? && header.match(pattern)
end

def spree_token
token = request.headers["X-Spree-Token"]
return if token.blank?

Spree::Deprecation.warn(
'The custom X-Spree-Token request header is deprecated and will be removed in the next release.' \
' Please use bearer token authorization header instead.'
)
token
end

def order_token
request.headers["X-Spree-Order-Token"] || params[:order_token]
end
Expand Down
16 changes: 2 additions & 14 deletions api/app/controllers/spree/api/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class CheckoutsController < Spree::Api::BaseController

rescue_from Spree::Order::InsufficientStock, with: :insufficient_stock_error

include Spree::Core::ControllerHelpers::Order

# TODO: Remove this after deprecated usage in #update is removed
include Spree::Core::ControllerHelpers::PaymentParameters

include Spree::Core::ControllerHelpers::Order

def next
authorize! :update, @order, order_token
if !expected_total_ok?(params[:expected_total])
Expand Down Expand Up @@ -116,17 +115,6 @@ def state_callback(before_or_after = :before)
end

def after_update_attributes
if params[:order] && params[:order][:coupon_code].present?
Spree::Deprecation.warn('This method is deprecated. Please use `Spree::Api::CouponCodesController#create` endpoint instead.')
handler = PromotionHandler::Coupon.new(@order)
handler.apply

if handler.error.present?
@coupon_message = handler.error
respond_with(@order, default_template: 'spree/api/orders/could_not_apply_coupon', status: 422)
return true
end
end
false
end

Expand Down
16 changes: 0 additions & 16 deletions api/app/controllers/spree/api/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class OrdersController < Spree::Api::BaseController
class_attribute :admin_payment_attributes
self.admin_payment_attributes = [:payment_method, :amount, :state, source: {}]

skip_before_action :authenticate_user, only: :apply_coupon_code

before_action :find_order, except: [:create, :mine, :current, :index]
around_action :lock_order, except: [:create, :mine, :current, :index, :show]

Expand Down Expand Up @@ -104,20 +102,6 @@ def mine
end
end

def apply_coupon_code
Spree::Deprecation.warn('This method is deprecated. Please use `Spree::Api::CouponCodesController#create` endpoint instead.')

authorize! :update, @order, order_token
@order.coupon_code = params[:coupon_code]
@handler = PromotionHandler::Coupon.new(@order).apply
if @handler.successful?
render "spree/api/promotions/handler", status: 200
else
logger.error("apply_coupon_code_error=#{@handler.error.inspect}")
render "spree/api/promotions/handler", status: 422
end
end

private

def order_params
Expand Down
6 changes: 0 additions & 6 deletions api/app/controllers/spree/api/taxonomies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ def show
respond_with(taxonomy)
end

# Because JSTree wants parameters in a *slightly* different format
def jstree
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)
show
end

def create
authorize! :create, Taxonomy
@taxonomy = Spree::Taxonomy.new(taxonomy_params)
Expand Down
5 changes: 0 additions & 5 deletions api/app/controllers/spree/api/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ def show
respond_with(@taxon)
end

def jstree
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)
show
end

def create
authorize! :create, Taxon
@taxon = Spree::Taxon.new(taxon_params)
Expand Down
1 change: 0 additions & 1 deletion api/app/views/spree/api/config/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true

json.default_country_id(Spree::Country.default.id)
json.default_country_iso(Spree::Config[:default_country_iso])

This file was deleted.

15 changes: 1 addition & 14 deletions api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
namespace :admin do
resources :users do
resource :api_key, controller: 'users/api_key', only: [:create, :destroy]

member do
put :generate_api_key # Deprecated
put :clear_api_key # Deprecated
end
end
end

Expand Down Expand Up @@ -68,7 +63,6 @@
member do
put :cancel
put :empty
put :apply_coupon_code
end

resources :coupon_codes, only: [:create, :destroy]
Expand Down Expand Up @@ -99,14 +93,7 @@
resources :states, only: [:index, :show]

resources :taxonomies do
member do
get :jstree
end
resources :taxons do
member do
get :jstree
end
end
resources :taxons
end

resources :taxons, only: [:index]
Expand Down
2 changes: 0 additions & 2 deletions api/lib/spree/api/responders/jbuilder_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def template
options[:default_template]
end
end

RablTemplate = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('RablTemplate', 'JbuilderTemplate')
end
end
end
Loading

0 comments on commit dc813e6

Please sign in to comment.