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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Merge commit from fork
Damian Legawiecea4a5db590ca
diff --git a/storefront/app/controllers/spree/order_status_controller.rb b/storefront/app/controllers/spree/order_status_controller.rbindex 5304aa4b7d..e9039cbd2d 100644--- a/storefront/app/controllers/spree/order_status_controller.rb+++ b/storefront/app/controllers/spree/order_status_controller.rb@@ -7,7 +7,7 @@ module Spree# validate email/order number and redirect to order page# POST /order_statusdef create- raise ActiveRecord::RecordNotFound if params[:number].blank?+ raise ActiveRecord::RecordNotFound if params[:number].blank? || params[:email].blank?@order = order_finder.new(number: params[:number], email: params[:email], store: current_store).execute.firstdiff --git a/storefront/app/controllers/spree/orders_controller.rb b/storefront/app/controllers/spree/orders_controller.rbindex 24eff25c39..e4db18a709 100644--- a/storefront/app/controllers/spree/orders_controller.rb+++ b/storefront/app/controllers/spree/orders_controller.rb@@ -10,11 +10,17 @@ module Spreebefore_action :assign_order_with_lock, only: :update+ rescue_from CanCan::AccessDenied do |exception|+ raise ActiveRecord::RecordNotFound+ end+# GET /orders/:iddef show@order = complete_order_finder.new(number: params[:id], token: params[:token], store: current_store).execute.first- raise ActiveRecord::RecordNotFound if @order.blank? || !authorize_access+ raise ActiveRecord::RecordNotFound if @order.blank?++ authorize! :show, @order, params[:token]@shipments = @order.shipments.includes(:stock_location, :address, selected_shipping_rate: :shipping_method, inventory_units: :line_item)end@@ -49,9 +55,7 @@ module Spreeprivatedef authorize_access- return true if @order.user_id.nil?-- @order.user == try_spree_current_user+ authorize! :show, @order, params[:token]enddef find_order_by_cookie@@ -65,7 +69,7 @@ module Spreeenddef accurate_title- if action_name == 'edit' || action_name == 'update'+ if ['edit', 'update'].include?(action_name)Spree.t(:shopping_cart)elseSpree.t(:order_number, number: @order&.number)diff --git a/storefront/spec/controllers/spree/order_status_controller_spec.rb b/storefront/spec/controllers/spree/order_status_controller_spec.rbindex 6e2725459e..32f0ca9481 100644--- a/storefront/spec/controllers/spree/order_status_controller_spec.rb+++ b/storefront/spec/controllers/spree/order_status_controller_spec.rb@@ -64,5 +64,13 @@ RSpec.describe Spree::OrderStatusController, type: :controller do}.to raise_error(ActiveRecord::RecordNotFound)endend++ context 'with blank email' do+ it 'raises ActiveRecord::RecordNotFound' do+ expect {+ post :create, params: { number: order.number, email: '' }+ }.to raise_error(ActiveRecord::RecordNotFound)+ end+ endendenddiff --git a/storefront/spec/controllers/spree/orders_controller_spec.rb b/storefront/spec/controllers/spree/orders_controller_spec.rbindex 0915fd6ccf..9ca8956eb8 100644--- a/storefront/spec/controllers/spree/orders_controller_spec.rb+++ b/storefront/spec/controllers/spree/orders_controller_spec.rb@@ -105,7 +105,8 @@ describe Spree::OrdersController, type: :controller doenddescribe '#show' do- let(:order) { create(:completed_order_with_totals, store: store, user: user) }+ let(:order) { create(:completed_order_with_totals, store: store) }+ let(:user) { nil }it 'renders the show template' doget :show, params: { id: order.number, token: order.token }@@ -144,13 +145,15 @@ describe Spree::OrdersController, type: :controller doendend- context 'when order belongs to another user' do- let(:order) { create(:completed_order_with_totals, store: store, user: create(:user)) }+ context 'when token is invalid' do+ it 'raises ActiveRecord::RecordNotFound' do+ expect { get :show, params: { id: order.number, token: 'invalid' } }.to raise_error(ActiveRecord::RecordNotFound)+ end+ end+ context 'when token is missing' doit 'raises ActiveRecord::RecordNotFound' do- expect do- get :show, params: { id: order.number, token: order.token }- end.to raise_error(ActiveRecord::RecordNotFound)+ expect { get :show, params: { id: order.number, token: '' } }.to raise_error(ActiveRecord::RecordNotFound)endendend