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.

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.rb
similarity index 100%
rename from core/app/jobs/spree/base_job.rb
rename to api/app/jobs/spree/base_job.rb
diff --git a/core/app/jobs/spree/webhooks/endpoints/make_request_job.rb b/api/app/jobs/spree/webhooks/endpoints/make_request_job.rb
similarity index 100%
rename from core/app/jobs/spree/webhooks/endpoints/make_request_job.rb
rename to api/app/jobs/spree/webhooks/endpoints/make_request_job.rb
diff --git a/api/app/models/spree/webhooks/endpoint.rb b/api/app/models/spree/webhooks/endpoint.rb
index 97b1f830d4..9ec80b5f46 100644
--- a/api/app/models/spree/webhooks/endpoint.rb
+++ b/api/app/models/spree/webhooks/endpoint.rb
@@ -2,15 +2,6 @@ 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
end
diff --git a/core/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb b/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb
similarity index 98%
rename from core/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb
rename to api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb
index 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
-:wa
let(:url) { 'http://url.com/' }
it 'it enqueues a HTTP request using Spree::Webhooks::Endpoints::MakeRequest' do
diff --git a/api/spec/models/spree/webhooks/endpoint_spec.rb b/api/spec/models/spree/webhooks/endpoint_spec.rb
deleted file mode 100644
index 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
-end
diff --git a/core/app/models/spree/webhooks/endpoint.rb b/core/app/models/spree/webhooks/endpoint.rb
deleted file mode 100644
index 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
-end
diff --git a/core/app/models/spree/webhooks/event.rb b/core/app/models/spree/webhooks/event.rb
deleted file mode 100644
index 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
-end
diff --git a/core/lib/spree/testing_support/factories/event.rb b/core/lib/spree/testing_support/factories/event.rb
deleted file mode 100644
index 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