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.

Use past tense for Webhook event names (#11432)

Damian Legawiec758da9138da8
diff --git a/api/app/models/spree/api/webhooks/order_decorator.rb b/api/app/models/spree/api/webhooks/order_decorator.rb
index 824de71de6..0ae590537a 100644
--- a/api/app/models/spree/api/webhooks/order_decorator.rb
+++ b/api/app/models/spree/api/webhooks/order_decorator.rb
@@ -4,12 +4,12 @@ module Spree
module OrderDecorator
def after_cancel
super
- queue_webhooks_requests!('order.cancel')
+ queue_webhooks_requests!('order.canceled')
end
def finalize!
super
- queue_webhooks_requests!('order.complete')
+ queue_webhooks_requests!('order.placed')
end
end
end
diff --git a/api/app/models/spree/api/webhooks/payment_decorator.rb b/api/app/models/spree/api/webhooks/payment_decorator.rb
index 44ef58cee6..37ecff10ff 100644
--- a/api/app/models/spree/api/webhooks/payment_decorator.rb
+++ b/api/app/models/spree/api/webhooks/payment_decorator.rb
@@ -4,7 +4,7 @@ module Spree
module PaymentDecorator
def after_void
super
- queue_webhooks_requests!('payment.void')
+ queue_webhooks_requests!('payment.voided')
end
end
end
diff --git a/api/app/models/spree/api/webhooks/shipment_decorator.rb b/api/app/models/spree/api/webhooks/shipment_decorator.rb
index 4026696370..19824edbc0 100644
--- a/api/app/models/spree/api/webhooks/shipment_decorator.rb
+++ b/api/app/models/spree/api/webhooks/shipment_decorator.rb
@@ -4,7 +4,7 @@ module Spree
module ShipmentDecorator
def after_ship
super
- queue_webhooks_requests!('shipment.ship')
+ queue_webhooks_requests!('shipment.shipped')
end
end
end
diff --git a/api/spec/integration/api/v2/platform/orders_spec.rb b/api/spec/integration/api/v2/platform/orders_spec.rb
index 1d49a92062..a05985d011 100644
--- a/api/spec/integration/api/v2/platform/orders_spec.rb
+++ b/api/spec/integration/api/v2/platform/orders_spec.rb
@@ -185,11 +185,11 @@ describe 'Orders API', swagger: true do
parameter name: :id, in: :path, type: :string
json_api_include_parameter(options[:include_example])
- response '200', 'record cancelled' do
+ response '200', 'record canceled' do
let(:id) { create(:completed_order_with_totals).id }
run_test!
end
- response '422', 'cannot be cancelled' do
+ response '422', 'cannot be canceled' do
run_test!
end
it_behaves_like 'record not found'
diff --git a/api/spec/models/spree/api/webhooks/order_spec.rb b/api/spec/models/spree/api/webhooks/order_spec.rb
index 987f21410e..0d270f3482 100644
--- a/api/spec/models/spree/api/webhooks/order_spec.rb
+++ b/api/spec/models/spree/api/webhooks/order_spec.rb
@@ -22,7 +22,7 @@ describe Spree::Order do
it 'executes QueueRequests.call with a order.cancel event and {} body after invoking cancel' do
Timecop.freeze(Time.local(1990)) do
order.cancel
- expect(queue_requests).to have_received(:call).with(event: 'order.cancel', body: body).once
+ expect(queue_requests).to have_received(:call).with(event: 'order.canceled', body: body).once
end
end
end
@@ -30,9 +30,9 @@ describe Spree::Order do
describe '#finalize!' do
let(:order) { described_class.create(email: '[email protected]', store: store) }
- it 'executes QueueRequests.call with a order.complete event and {} body after invoking finalize!' do
+ it 'executes QueueRequests.call with a order.placed event and {} body after invoking finalize!' do
order.finalize!
- expect(queue_requests).to have_received(:call).with(event: 'order.complete', body: body).once
+ expect(queue_requests).to have_received(:call).with(event: 'order.placed', body: body).once
end
end
end
diff --git a/api/spec/models/spree/api/webhooks/payment_spec.rb b/api/spec/models/spree/api/webhooks/payment_spec.rb
index 06ed01d027..e948ebe2e7 100644
--- a/api/spec/models/spree/api/webhooks/payment_spec.rb
+++ b/api/spec/models/spree/api/webhooks/payment_spec.rb
@@ -20,9 +20,9 @@ describe Spree::Payment do
after { ENV['DISABLE_SPREE_WEBHOOKS'] = 'true' }
- it 'executes QueueRequests.call with a payment.void event and {} body after invoking void' do
+ it 'executes QueueRequests.call with a payment.voided event and {} body after invoking void' do
payment.void
- expect(queue_requests).to have_received(:call).with(event: 'payment.void', body: body).once
+ expect(queue_requests).to have_received(:call).with(event: 'payment.voided', body: body).once
end
end
diff --git a/api/spec/models/spree/api/webhooks/shipment_spec.rb b/api/spec/models/spree/api/webhooks/shipment_spec.rb
index 2831391178..7df966e8f2 100644
--- a/api/spec/models/spree/api/webhooks/shipment_spec.rb
+++ b/api/spec/models/spree/api/webhooks/shipment_spec.rb
@@ -19,10 +19,10 @@ describe Spree::Shipment do
let(:queue_requests) { instance_double(Spree::Webhooks::Subscribers::QueueRequests) }
- it 'executes QueueRequests.call with a shipment.ship event and {} body after invoking ship' do
+ it 'executes QueueRequests.call with a shipment.shipped event and {} body after invoking ship' do
shipment.cancel # previous state that allows the object be shipped
shipment.ship
- expect(queue_requests).to have_received(:call).with(event: 'shipment.ship', body: body).once
+ expect(queue_requests).to have_received(:call).with(event: 'shipment.shipped', body: body).once
end
end
end
diff --git a/api/spec/models/spree/webhooks/subscriber_spec.rb b/api/spec/models/spree/webhooks/subscriber_spec.rb
index 36241c4f09..995545f895 100644
--- a/api/spec/models/spree/webhooks/subscriber_spec.rb
+++ b/api/spec/models/spree/webhooks/subscriber_spec.rb
@@ -26,8 +26,8 @@ describe Spree::Webhooks::Subscriber do
describe '.urls_for' do
subject { described_class.urls_for(event) }
- let(:event) { 'order.complete' }
- let(:subscriptions) { ['order.complete'] }
+ let(:event) { 'order.placed' }
+ let(:subscriptions) { ['order.placed'] }
let!(:subscriber) { described_class.create(url: url, subscriptions: subscriptions, active: true) }
let(:url) { 'https://url1.com/' }