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.

Fix 'ensure_order_token' accepting empty string as valid input

Karol Szustera20a53ca7520
diff --git a/api/app/controllers/spree/api/v2/storefront/order_status_controller.rb b/api/app/controllers/spree/api/v2/storefront/order_status_controller.rb
index c1d1658405..a5980dddb4 100644
--- a/api/app/controllers/spree/api/v2/storefront/order_status_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/order_status_controller.rb
@@ -29,7 +29,7 @@ module Spree
end
def ensure_order_token
- raise ActiveRecord::RecordNotFound unless order_token
+ raise ActiveRecord::RecordNotFound unless order_token.present?
end
end
end
diff --git a/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb b/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb
index 41a7359fc9..46b43ea599 100644
--- a/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb
+++ b/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb
@@ -13,6 +13,14 @@ describe 'Storefront API v2 OrderStatus spec', type: :request do
it_behaves_like 'returns 404 HTTP status'
end
+ context 'as a guest user with blank token' do
+ let(:headers_order_token) { { 'X-Spree-Order-Token' => '' } }
+
+ before { get "/api/v2/storefront/order_status/#{order.number}", headers: headers_order_token }
+
+ it_behaves_like 'returns 404 HTTP status'
+ end
+
context 'as a guest user with invalid token' do
let(:headers_order_token) { { 'X-Spree-Order-Token' => 'WRONG' } }