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
Pin where a certificate document is served from
Łukasz Adamczyk6d50163cf28b
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/companies/tax_exemption_certificates_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/companies/tax_exemption_certificates_controller_spec.rbindex 3da14f26db..00d7266e16 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/companies/tax_exemption_certificates_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/companies/tax_exemption_certificates_controller_spec.rb@@ -85,6 +85,31 @@ RSpec.describe Spree::Api::V3::Admin::Companies::TaxExemptionCertificatesControlend# Without the rescue this is a 500.+ # The URL has to be our own streaming endpoint, not a storage link — that is+ # what makes admin credentials apply to every read of a confidential document.+ it 'points the document at the download endpoint' do+ post :create, params: {+ company_id: company.prefixed_id,+ certificate_number: 'DE-1', reason_code: 'resale',+ document: pdf_blob.signed_id+ }, as: :json++ certificate = company.tax_exemption_certificates.sole+ expect(json_response['document_url']).to eq(+ "/api/v3/admin/companies/#{company.prefixed_id}/tax_exemption_certificates/#{certificate.prefixed_id}/download"+ )+ expect(json_response['document_url']).not_to include('rails/active_storage')+ end++ it 'reports no document url when nothing is attached' do+ post :create, params: {+ company_id: company.prefixed_id, certificate_number: 'DE-2', reason_code: 'resale'+ }, as: :json++ expect(json_response['document_url']).to be_nil+ expect(json_response['document_filename']).to be_nil+ end+it 'rejects a tampered signed id with a validation error' dopost :create, params: {company_id: company.prefixed_id,