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.

Read the live provider on every checklist, the stamp only on the list

Damian Legawiec75aefef64111
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
index 98de3e328f..85e950fb5e 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
@@ -161,19 +161,31 @@ RSpec.describe Spree::Api::V3::Admin::PaymentMethodsController, type: :controlle
# gave back. They are absent from the schema so no form offers them,
# and ignored here so a client cannot write one anyway and break the
# signature check that depends on it.
+ # A gateway of its own, declaring a real internal preference. Stubbing
+ # `preference_internal` on the shared Bogus class would be read by the
+ # class-level schema memo as well, caching a schema without its password
+ # key for every later example in the process.
it 'ignores a preference the system owns' do
- allow_any_instance_of(Spree::Gateway::Bogus).to receive(:preference_internal).
- and_wrap_original { |original, name| name == :dummy_secret_key || original.call(name) }
+ gateway_class = Class.new(Spree::Gateway) do
+ def self.name = 'InternalPreferenceGateway'
+
+ preference :issued_secret, :password, internal: true
+ end
+ stub_const('InternalPreferenceGateway', gateway_class)
+ allow(Spree::PaymentMethod).to receive(:providers).and_return(
+ Spree::PaymentMethod.providers + [gateway_class]
+ )
+ gateway = gateway_class.create!(store: store, name: 'Issued', preferred_issued_secret: 'whsec_real')
patch :update,
params: {
- id: payment_method.prefixed_id,
- preferences: { dummy_secret_key: 'sk_live_written_by_a_client' }
+ id: gateway.prefixed_id,
+ preferences: { issued_secret: 'whsec_written_by_a_client' }
},
as: :json
expect(response).to have_http_status(:ok)
- expect(payment_method.reload.preferred_dummy_secret_key).to eq('sk_live_existing_secret')
+ expect(gateway.reload.preferred_issued_secret).to eq('whsec_real')
end
it 'replaces the secret when the submitted value is a new plaintext' do
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/sellers_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/sellers_controller_spec.rb
index a4678a59fb..bb43d28c5c 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/sellers_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/sellers_controller_spec.rb
@@ -88,6 +88,17 @@ RSpec.describe Spree::Api::V3::Admin::SellersController, type: :controller do
expect(response).to have_http_status(:ok)
end
+
+ # The checklist is where staff decide whether to admit a seller, so a
+ # stale answer here is the one that costs something — a seller who has
+ # finished with Stripe left looking unfinished, or the reverse.
+ it 'is done for the checklist staff read' do
+ expect_any_instance_of(Spree::PayoutProvider::System).to receive(:onboarded?).at_least(:once).and_return(true)
+
+ get :onboarding, params: { id: seller.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ end
end
describe 'GET #show' do
diff --git a/spree/api/spec/controllers/spree/api/v3/seller/onboarding_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/onboarding_controller_spec.rb
index 5b70d3bc34..fddf46f105 100644
--- a/spree/api/spec/controllers/spree/api/v3/seller/onboarding_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/seller/onboarding_controller_spec.rb
@@ -21,6 +21,23 @@ RSpec.describe Spree::Api::V3::Seller::OnboardingController, type: :controller d
request.headers['X-Spree-Seller-Id'] = seller.prefixed_id
end
+ # The seller is looking at their own checklist to find out what is left to
+ # do, so a cached answer is the wrong one here: someone who has just
+ # finished with the provider must not be told they have not.
+ describe 'the payout account requirement' do
+ before do
+ Spree::SellerRequirements::PayoutAccount.create!(store: store, name: 'Payout account', required: true)
+ end
+
+ it 'asks the provider rather than reading the stamp' do
+ expect_any_instance_of(Spree::PayoutProvider::System).to receive(:onboarded?).at_least(:once).and_return(true)
+
+ get :show, as: :json
+
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
describe 'GET #show' do
it 'reads as finished when the marketplace asks for nothing' do
get :show, as: :json