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
Report integration activation failures without the attribute prefix
Damian Legawieca9505f679ba8
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/integrations_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/integrations_controller_spec.rbindex d638570ff8..1820b651c1 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/integrations_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/integrations_controller_spec.rb@@ -102,7 +102,8 @@ RSpec.describe Spree::Api::V3::Admin::IntegrationsController, type: :controllerpost :create, params: { type: 'carrier', active: true, preferences: { api_key: 'wrong' } }, as: :jsonexpect(response).to have_http_status(:unprocessable_content)- expect(json_response['error']['details']['active']).to include('invalid api key')+ expect(json_response['error']['details']['base']).to include('invalid api key')+ expect(json_response['error']['message']).to eq('invalid api key')endenddiff --git a/spree/core/app/models/spree/integration.rb b/spree/core/app/models/spree/integration.rbindex cbd6859fda..7d4dc3765e 100644--- a/spree/core/app/models/spree/integration.rb+++ b/spree/core/app/models/spree/integration.rb@@ -138,10 +138,14 @@ module Spreeerrors.add(:type, Spree.t('errors.messages.integration_type_not_registered'))end+ # On :base, not :active — the vendor's message ("This api key is no+ # longer active…") is a record-level failure, and an attribute error+ # would render with the humanized attribute prepended ("Active This+ # api key…").def must_connect_when_activatingreturn if can_connect?- errors.add(:active, connection_error_message.presence || Spree.t('errors.messages.integration_connection_failed'))+ errors.add(:base, connection_error_message.presence || Spree.t('errors.messages.integration_connection_failed'))endendenddiff --git a/spree/core/spec/models/spree/integration_spec.rb b/spree/core/spec/models/spree/integration_spec.rbindex 3e9fa708a7..bbf353da48 100644--- a/spree/core/spec/models/spree/integration_spec.rb+++ b/spree/core/spec/models/spree/integration_spec.rb@@ -89,7 +89,8 @@ RSpec.describe Spree::Integration, type: :model dointegration = TestIntegrations::Failing.new(store: @default_store, active: true)expect(integration).not_to be_valid- expect(integration.errors[:active]).to include('bad credentials')+ expect(integration.errors[:base]).to include('bad credentials')+ expect(integration.errors.full_messages).to include('bad credentials')endit 'does not re-verify an already active integration on unrelated saves' dodiff --git a/spree/easypost/spec/models/spree_easypost/integration_spec.rb b/spree/easypost/spec/models/spree_easypost/integration_spec.rbindex 5e0d195bfe..9fc5a824aa 100644--- a/spree/easypost/spec/models/spree_easypost/integration_spec.rb+++ b/spree/easypost/spec/models/spree_easypost/integration_spec.rb@@ -48,7 +48,7 @@ RSpec.describe SpreeEasyPost::Integration dointegration.active = trueexpect(integration).not_to be_valid- expect(integration.errors[:active]).to be_present+ expect(integration.errors[:base]).to be_presentendendend