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
Do not set default Endpoint subscriptions. Move files from /core to /api.
Sebastian Palmabf80a1f6b6c4
diff --git a/core/app/jobs/spree/base_job.rb b/api/app/jobs/spree/base_job.rbsimilarity index 100%rename from core/app/jobs/spree/base_job.rbrename to api/app/jobs/spree/base_job.rbdiff --git a/core/app/jobs/spree/webhooks/endpoints/make_request_job.rb b/api/app/jobs/spree/webhooks/endpoints/make_request_job.rbsimilarity index 100%rename from core/app/jobs/spree/webhooks/endpoints/make_request_job.rbrename to api/app/jobs/spree/webhooks/endpoints/make_request_job.rbdiff --git a/api/app/models/spree/webhooks/endpoint.rb b/api/app/models/spree/webhooks/endpoint.rbindex 97b1f830d4..9ec80b5f46 100644--- a/api/app/models/spree/webhooks/endpoint.rb+++ b/api/app/models/spree/webhooks/endpoint.rb@@ -2,15 +2,6 @@ module Spreemodule Webhooksclass Endpoint < Spree::Baseself.table_name = 'spree_webhooks_endpoints'-- before_save :assign_default_subscriptions,- if: proc { ActiveRecord::Base.connection.adapter_name == 'Mysql2' }-- private-- def assign_default_subscriptions- self.subscriptions = ['*'] if subscriptions.blank?- endendendenddiff --git a/core/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb b/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rbsimilarity index 98%rename from core/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rbrename to api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rbindex e85da09f97..e8c9f82be2 100644--- a/core/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb+++ b/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb@@ -1,7 +1,6 @@require 'spec_helper'describe Spree::Webhooks::Endpoints::MakeRequestJob, :inline_jobs do-:walet(:url) { 'http://url.com/' }it 'it enqueues a HTTP request using Spree::Webhooks::Endpoints::MakeRequest' dodiff --git a/api/spec/models/spree/webhooks/endpoint_spec.rb b/api/spec/models/spree/webhooks/endpoint_spec.rbdeleted file mode 100644index 02bc624d1e..0000000000--- a/api/spec/models/spree/webhooks/endpoint_spec.rb+++ /dev/null@@ -1,47 +0,0 @@-require 'spec_helper'--module Spree- describe Webhooks::Endpoint, type: :model do- context 'after-save sets default subscriptions' do- subject { build(:endpoint, subscriptions: subscriptions) }-- let(:default_all_subscriptions) { ['*'] }-- before do- subject.save- subject.reload- end-- context 'mysql', if: ActiveRecord::Base.connection.adapter_name == 'Mysql2' do- context 'without subscriptions when initializing an endpoint' do- let(:subscriptions) { nil }-- it 'sets the default subscriptions' do- expect(subject.subscriptions).to eq(default_all_subscriptions)- end- end-- context 'with subscriptions when initializing an endpoint' do- subject { build(:endpoint, subscriptions: subscriptions) }-- let(:subscriptions) { ['model.event'] }-- it 'after-save does not set default subscriptions' do- expect(subject.subscriptions).to eq(subscriptions)- end- end- end-- context 'pg', if: ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' do- let(:subscriptions) { '' }-- it 'does not execute the callback as Postgres implements default JSONB values' do- # Although an empty string isn't a working subscription- # what's being tested is setting default susbcriptions,- # since MySQL does not support default values for JSON.- expect(subject.subscriptions).to eq(subscriptions)- end- end- end- end-enddiff --git a/core/app/models/spree/webhooks/endpoint.rb b/core/app/models/spree/webhooks/endpoint.rbdeleted file mode 100644index 97b1f830d4..0000000000--- a/core/app/models/spree/webhooks/endpoint.rb+++ /dev/null@@ -1,16 +0,0 @@-module Spree- module Webhooks- class Endpoint < Spree::Base- self.table_name = 'spree_webhooks_endpoints'-- before_save :assign_default_subscriptions,- if: proc { ActiveRecord::Base.connection.adapter_name == 'Mysql2' }-- private-- def assign_default_subscriptions- self.subscriptions = ['*'] if subscriptions.blank?- end- end- end-enddiff --git a/core/app/models/spree/webhooks/event.rb b/core/app/models/spree/webhooks/event.rbdeleted file mode 100644index 586d0ffa6a..0000000000--- a/core/app/models/spree/webhooks/event.rb+++ /dev/null@@ -1,7 +0,0 @@-module Spree- module Webhooks- class Event < Spree::Base- self.table_name = 'spree_webhooks_events'- end- end-enddiff --git a/core/lib/spree/testing_support/factories/event.rb b/core/lib/spree/testing_support/factories/event.rbdeleted file mode 100644index d341e9ea9a..0000000000--- a/core/lib/spree/testing_support/factories/event.rb+++ /dev/null@@ -1,6 +0,0 @@-FactoryBot.define do- factory :event, class: Spree::Webhooks::Event do- enabled { true }- name { 'order.create' }- end-end