Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Removed unreachable API routes and controller actions (#14802)

Damian Legawiec37a4a0403ad5
diff --git a/spree/api/app/controllers/spree/api/v3/admin/admin_users_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/admin_users_controller.rb
index 2a858683c0..6d640dcabe 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/admin_users_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/admin_users_controller.rb
@@ -14,11 +14,6 @@ module Spree
# grantable separately from store configuration (6.0-admin-rbac.md).
scoped_resource :staff
- # POST is not exposed — staff are created via invitations.
- def create
- head :method_not_allowed
- end
-
# DELETE /api/v3/admin/admin_users/:id
# Removes role assignments for the current store rather than deleting
# the account globally. The user keeps access to any other stores.
diff --git a/spree/api/app/controllers/spree/api/v3/admin/invitations_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/invitations_controller.rb
index 04a6ead3e4..b27832a759 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/invitations_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/invitations_controller.rb
@@ -34,13 +34,6 @@ module Spree
render json: serialize_resource(@resource)
end
- # Invitations are immutable post-create — UI calls `resend` for
- # token rotation, `destroy` to revoke. Clearing the action set
- # keeps the surface honest if a client ever fires PATCH directly.
- def update
- head :method_not_allowed
- end
-
protected
def model_class
diff --git a/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb
index aa1b61ae7a..d0c2c0d97c 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb
@@ -3,8 +3,7 @@ module Spree
module V3
module Admin
# Admin CRUD for `Spree::PriceList`, plus the lifecycle transitions
- # (`activate` / `deactivate`) and the spreadsheet's data feed
- # (`prices`).
+ # (`activate` / `deactivate`).
#
# Everything writable on the list itself — name, schedule, match
# policy, nested rules (`rules: [...]`), and individual price
@@ -25,7 +24,7 @@ module Spree
# before_actions by method name, so this would otherwise
# *replace* the parent's narrower filter and break the standard
# actions. Wrapping it under a different name keeps both.
- before_action :load_member_resource, only: [:activate, :deactivate, :prices]
+ before_action :load_member_resource, only: [:activate, :deactivate]
# GET /api/v3/admin/price_lists/price_rule_types
#
@@ -69,29 +68,6 @@ module Spree
end
end
- # GET /api/v3/admin/price_lists/:id/prices
- #
- # The spreadsheet editor's data source. Returns every Price row
- # in this list (filtered by `?currency=`), eager-loading
- # `variant.product` + option values so each cell can render
- # product name, variant options and SKU without N+1.
- def prices
- authorize! :read, @resource
- currency = params[:currency].presence || current_store.default_currency
- prices = @resource.prices
- .includes(variant: [:product, { option_values: :option_type }])
- .where(currency: currency)
- .joins(variant: :product)
- .order(Arel.sql("#{Spree::Product.table_name}.name ASC"))
- .order(Arel.sql("#{Spree::Variant.table_name}.position ASC"))
- .order(min_quantity: :asc)
-
- render json: {
- data: prices.map { |p| serialize_price(p) },
- meta: { currency: currency, count: prices.size }
- }
- end
-
protected
def model_class
@@ -139,36 +115,12 @@ module Spree
# Loads the record without the action-derived authorization
# `set_resource` runs (which would check `:activate` /
- # `:deactivate` / `:prices` — actions that abilities don't
- # grant). The per-action methods below explicitly call
- # `authorize!` with the standard action that ability rules
- # actually mention (`:update` / `:read`).
+ # `:deactivate` — actions that abilities don't grant). The
+ # per-action methods explicitly call `authorize!` with
+ # `:update`, which ability rules actually mention.
def load_member_resource
@resource = find_resource
end
-
- # Hand-rolled flat shape for the spreadsheet — keeps the payload
- # narrow (no nested variant/product/option_value objects) and
- # avoids paying for the admin Price serializer when we only need
- # ~6 fields per row. The grouping the UI does (rows → product
- # header) is driven entirely off `product_id`/`product_name`.
- def serialize_price(price)
- variant = price.variant
- product = variant.product
- {
- id: price.prefixed_id,
- variant_id: variant.prefixed_id,
- product_id: product.prefixed_id,
- product_name: product.name,
- variant_label: variant.options_text.presence,
- sku: variant.sku,
- currency: price.currency,
- min_quantity: price.min_quantity,
- amount: price.amount&.to_s,
- compare_at_amount: price.compare_at_amount&.to_s
- }
- end
-
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/store/carts/fulfillments_controller.rb b/spree/api/app/controllers/spree/api/v3/store/carts/fulfillments_controller.rb
index e297a71cf9..1b890a5a17 100644
--- a/spree/api/app/controllers/spree/api/v3/store/carts/fulfillments_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/store/carts/fulfillments_controller.rb
@@ -9,15 +9,6 @@ module Spree
before_action :find_cart!
- # GET /api/v3/store/carts/:cart_id/fulfillments
- def index
- fulfillments = @cart.fulfillments.includes(delivery_rates: :delivery_method)
- render json: {
- data: fulfillments.map { |s| Spree.api.fulfillment_serializer.new(s, params: serializer_params).to_h },
- meta: { count: fulfillments.size }
- }
- end
-
# PATCH /api/v3/store/carts/:cart_id/fulfillments/:id
# Selects a delivery rate, and for pickup_point methods a concrete
# pickup point (validated against the provider, then frozen into
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 2f1f8b51df..af36695586 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -1,6 +1,7 @@
Spree::Core::Engine.add_routes do
namespace :api, defaults: { format: 'json' } do
- namespace :v3 do
+ # A JSON API has no form pages, so no resource gets `new` or `edit` routes.
+ namespace :v3, except: [:new, :edit] do
namespace :store do
# Authentication
post 'auth/login', to: 'auth#create'