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.

Fix MySQL broken HasWebhooks examples.

Sebastian Palmaedb66a62acd9
diff --git a/api/app/models/concerns/spree/webhooks/has_webhooks.rb b/api/app/models/concerns/spree/webhooks/has_webhooks.rb
index e2c476ec8a..6ff9a35614 100644
--- a/api/app/models/concerns/spree/webhooks/has_webhooks.rb
+++ b/api/app/models/concerns/spree/webhooks/has_webhooks.rb
@@ -30,7 +30,7 @@ module Spree
def payload
resource_serializer.new(self).serializable_hash
- rescue NoMethodError
+ rescue NameError, NoMethodError
{}
end
diff --git a/api/app/services/spree/webhooks/endpoints/make_request.rb b/api/app/services/spree/webhooks/endpoints/make_request.rb
index dcab4e1e7e..b771e4b584 100644
--- a/api/app/services/spree/webhooks/endpoints/make_request.rb
+++ b/api/app/services/spree/webhooks/endpoints/make_request.rb
@@ -5,7 +5,6 @@ module Spree
prepend Spree::ServiceModule::Base
def call(url:)
- p url
run :make_request
end
diff --git a/api/app/services/spree/webhooks/endpoints/queue_requests.rb b/api/app/services/spree/webhooks/endpoints/queue_requests.rb
index e95715e26d..aa3f24ec43 100644
--- a/api/app/services/spree/webhooks/endpoints/queue_requests.rb
+++ b/api/app/services/spree/webhooks/endpoints/queue_requests.rb
@@ -3,7 +3,6 @@ module Spree
prepend Spree::ServiceModule::Base
def call(event:, payload:)
- p payload
urls_subscribed_to(event).each do |url|
Spree::Webhooks::Endpoints::MakeRequestJob.perform_later(url)
end
diff --git a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb
index c498b9f28d..f54b7e82c5 100644
--- a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb
+++ b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
-module Spree
- class Webhooks::Product < ActiveRecord::Base
+module Test
+ class Product < ActiveRecord::Base
self.table_name = 'test_products'
include Spree::Webhooks::HasWebhooks
@@ -9,20 +9,18 @@ module Spree
end
describe Spree::Webhooks::HasWebhooks do
- let(:connection) { ActiveRecord::Base.connection }
-
- before do
- connection.create_table :test_products, force: true do |t|
+ before(:all) do
+ ActiveRecord::Base.connection.create_table :test_products, force: true do |t|
t.string :name
end
end
- after do
- connection.drop_table :test_products, if_exists: true
+ after(:all) do
+ ActiveRecord::Base.connection.drop_table :test_products, if_exists: true
end
context 'with a Spree::Webhooks class including the module' do
- let!(:product) { Spree::Webhooks::Product.create(name: 'test') }
+ let!(:product) { Test::Product.create(name: 'test') }
context 'after commit on create' do
it 'does not execute the webhook callback' do
diff --git a/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb
index 3a3c58e426..b463ba11e4 100644
--- a/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb
+++ b/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb
@@ -5,14 +5,17 @@ describe Spree::Api::V2::Platform::MenuItemSerializer do
let(:menu) { create(:menu) }
let(:menu_item) { create(:menu_item, menu: menu, linked_resource: create(:taxon)) }
- let!(:children) do
+ let(:children) do
[
create(:menu_item, parent_id: menu_item.id, menu: menu),
create(:menu_item, parent_id: menu_item.id, menu: menu)
]
end
- before { menu_item.reload }
+ before do
+ allow_any_instance_of(Spree::Base).to receive(:queue_webhooks_requests!)
+ children
+ end
it { expect(subject.serializable_hash).to be_kind_of(Hash) }