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
Rename all occurrences of webhooks "body" to "webhook_payload_body". (#11528)
sebffc865ad7b7f
diff --git a/api/app/jobs/spree/webhooks/subscribers/make_request_job.rb b/api/app/jobs/spree/webhooks/subscribers/make_request_job.rbindex d141146eda..cfa8a15416 100644--- a/api/app/jobs/spree/webhooks/subscribers/make_request_job.rb+++ b/api/app/jobs/spree/webhooks/subscribers/make_request_job.rb@@ -4,9 +4,11 @@ module Spreeclass MakeRequestJob < Spree::BaseJobqueue_as :spree_webhooks- def perform(body, event_name, subscriber)+ def perform(webhook_payload_body, event_name, subscriber)Spree::Webhooks::Subscribers::HandleRequest.new(- body: body, event_name: event_name, subscriber: subscriber+ event_name: event_name,+ subscriber: subscriber,+ webhook_payload_body: webhook_payload_body).callendenddiff --git a/api/app/models/concerns/spree/webhooks/has_webhooks.rb b/api/app/models/concerns/spree/webhooks/has_webhooks.rbindex 22457c43a3..a97ecc715e 100644--- a/api/app/models/concerns/spree/webhooks/has_webhooks.rb+++ b/api/app/models/concerns/spree/webhooks/has_webhooks.rb@@ -9,10 +9,10 @@ module Spreeafter_update_commit(proc { queue_webhooks_requests!(inferred_event_name(:update)) })def queue_webhooks_requests!(event_name)- return if disable_spree_webhooks? || body.blank?+ return if disable_spree_webhooks? || webhook_payload_body.blank?return if update_event?(event_name) && updating_only_timestamps?- Spree::Webhooks::Subscribers::QueueRequests.call(body: body, event_name: event_name)+ Spree::Webhooks::Subscribers::QueueRequests.call(event_name: event_name, webhook_payload_body: webhook_payload_body)enddef self.default_webhook_events@@ -29,7 +29,7 @@ module Spreeprivate- def body+ def webhook_payload_bodyresource_serializer.new(self).serializable_hash.to_jsonenddiff --git a/api/app/services/spree/webhooks/subscribers/handle_request.rb b/api/app/services/spree/webhooks/subscribers/handle_request.rbindex d3063c75da..59a7a58c9f 100644--- a/api/app/services/spree/webhooks/subscribers/handle_request.rb+++ b/api/app/services/spree/webhooks/subscribers/handle_request.rb@@ -4,18 +4,18 @@ module Spreemodule Webhooksmodule Subscribersclass HandleRequest- def initialize(body:, event_name:, subscriber:)- @body = JSON.parse(body)+ def initialize(event_name:, subscriber:, webhook_payload_body:)@event_name = event_name@subscriber = subscriber+ @webhook_payload_body = JSON.parse(webhook_payload_body)enddef callRails.logger.debug(msg("sending to '#{url}'"))- Rails.logger.debug(msg("body: #{body_with_event_metadata}"))+ Rails.logger.debug(msg("webhook_payload_body: #{body_with_event_metadata}"))if request.unprocessable_uri?- return process(:warn, msg("can not make a request to '#{url}'"))+ return process(:warn, msg("can not make a request to '#{url}'"))endreturn process(:warn, msg("failed for '#{url}'")) if request.failed_request?@@ -24,9 +24,11 @@ module Spreeprivate- attr_reader :body, :event_name, :subscriber+ attr_reader :webhook_payload_body, :event_name, :subscriber- delegate :url, to: :subscriber+ delegate :execution_time, :failed_request?, :response_code, :success?, :unprocessable_uri?, to: :request+ delegate :id, :url, to: :subscriber+ delegate :created_at, :id, to: :event, prefix: truedef process(log_level, msg)Rails.logger.public_send(log_level, msg)@@ -37,13 +39,13 @@ module Spreedef request@request ||=- Spree::Webhooks::Subscribers::MakeRequest.new(body: body_with_event_metadata, url: url)+ Spree::Webhooks::Subscribers::MakeRequest.new(webhook_payload_body: body_with_event_metadata, url: url)endalias make_request requestdef body_with_event_metadata- body.- merge(event_created_at: event.created_at, event_id: event.id, event_type: event.name).+ webhook_payload_body.+ merge(event_created_at: event_created_at, event_id: event_id, event_type: event.name).to_jsonend@@ -55,10 +57,10 @@ module Spreedef update_event(msg)event.update(- execution_time: request.execution_time,+ execution_time: execution_time,request_errors: msg,- response_code: request.response_code,- success: request.success?+ response_code: response_code,+ success: success?)enddiff --git a/api/app/services/spree/webhooks/subscribers/make_request.rb b/api/app/services/spree/webhooks/subscribers/make_request.rbindex a954856335..eb673bdeb9 100644--- a/api/app/services/spree/webhooks/subscribers/make_request.rb+++ b/api/app/services/spree/webhooks/subscribers/make_request.rb@@ -4,10 +4,10 @@ module Spreemodule Webhooksmodule Subscribersclass MakeRequest- def initialize(body:, url:)- @body = body+ def initialize(url:, webhook_payload_body:)@execution_time_in_milliseconds = 0@url = url+ @webhook_payload_body = webhook_payload_body@webhooks_timeout = ENV['SPREE_WEBHOOKS_TIMEOUT']end@@ -34,7 +34,7 @@ module Spreeprivate- attr_reader :body, :execution_time_in_milliseconds, :url, :webhooks_timeout+ attr_reader :execution_time_in_milliseconds, :url, :webhook_payload_body, :webhooks_timeoutHEADERS = { 'Content-Type' => 'application/json' }.freezeprivate_constant :HEADERS@@ -50,7 +50,7 @@ module Spreedef requestreq = Net::HTTP::Post.new(uri_path, HEADERS)- req.body = body+ req.body = webhook_payload_body@request ||= beginstart_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)request_result = http.request(req)diff --git a/api/app/services/spree/webhooks/subscribers/queue_requests.rb b/api/app/services/spree/webhooks/subscribers/queue_requests.rbindex 6db2a943ee..ccdecfac1c 100644--- a/api/app/services/spree/webhooks/subscribers/queue_requests.rb+++ b/api/app/services/spree/webhooks/subscribers/queue_requests.rb@@ -4,9 +4,11 @@ module Spreeclass QueueRequestsprepend Spree::ServiceModule::Base- def call(body:, event_name:)+ def call(event_name:, webhook_payload_body:)Spree::Webhooks::Subscriber.active.with_urls_for(event_name).each do |subscriber|- Spree::Webhooks::Subscribers::MakeRequestJob.perform_later(body, event_name, subscriber)+ Spree::Webhooks::Subscribers::MakeRequestJob.perform_later(+ webhook_payload_body, event_name, subscriber+ )endendenddiff --git a/api/lib/spree/api/testing_support/matchers/webhooks.rb b/api/lib/spree/api/testing_support/matchers/webhooks.rbindex 29d451aa14..b1ddb266ac 100644--- a/api/lib/spree/api/testing_support/matchers/webhooks.rb+++ b/api/lib/spree/api/testing_support/matchers/webhooks.rb@@ -1,6 +1,6 @@# Passes if executing the code in the block there is a# `Spree::Webhooks::Subscribers::QueueRequests.call` method-# call with the given `event` and `body` arguments just once.+# call with the given `event` and `webhook_payload_body` arguments just once.## @example# expect { order.complete }.to emit_webhook_event('order.paid')@@ -11,7 +11,7 @@## It can also be negated, resulting in the expectation# waiting to not receive a `call` method call with the-# given `event` and `body` (`once` isn't taken into consideration).+# given `event` and `webhook_payload_body` (`once` isn't taken into consideration).## @example# expect { order.complete }.not_to emit_webhook_event('order.paid')@@ -22,7 +22,7 @@## == Notes#-# The matcher relies on a `body` method previously defined which+# The matcher relies on a `webhook_payload_body` method previously defined which# isn't added to the matcher definition, because it acts in a different# way depending on what's the resource being tested.#@@ -36,25 +36,25 @@ RSpec::Matchers.define :emit_webhook_event do |event_to_emit|with_webhooks_enabled { Timecop.freeze { block.call } }expect(queue_requests).to(- have_received(:call).with(body: body.to_json, event_name: event_to_emit).once+ have_received(:call).with(event_name: event_to_emit, webhook_payload_body: webhook_payload_body.to_json).once)end- def block_body_definition(obj_method)+ def block_definition(obj_method)# positive look-behinds must have a fixed length, using a straightforward match insteadobj_method.source.squish[/(expect *({|do) *)(.*?)( *(}|end).(not_)*to)/, 3]endfailure_message do |obj_method|- block_body_def = block_body_definition(obj_method)- "Expected that executing `#{block_body_def}` emits the `#{event_to_emit}` Webhook event.\n" \- "Check that `#{block_body_def}` does implement `queue_webhooks_requests!` for " \- "`#{event_to_emit}` with the following body: \n\n#{body}."+ block_def = block_definition(obj_method)+ "Expected that executing `#{block_def}` emits the `#{event_to_emit}` Webhook event.\n" \+ "Check that `#{block_def}` does implement `queue_webhooks_requests!` for " \+ "`#{event_to_emit}` with the following webhook_payload_body: \n\n#{webhook_payload_body}."endfailure_message_when_negated do |obj_method|- "Expected that executing `#{block_body_definition(obj_method)}` does not " \- "emit the `#{event_to_emit}` Webhook event with the following body: #{body}."+ "Expected that executing `#{block_definition(obj_method)}` does not " \+ "emit the `#{event_to_emit}` Webhook event with the following webhook_payload_body: #{webhook_payload_body}."endsupports_block_expectationsdiff --git a/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb b/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rbindex ae3def774d..3a180d2080 100644--- a/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb+++ b/api/spec/jobs/spree/webhooks/endpoints/make_request_job_spec.rb@@ -1,17 +1,17 @@require 'spec_helper'describe Spree::Webhooks::Subscribers::MakeRequestJob do- let(:body) { {} }let(:event) { 'order.cancel' }let(:queue) { 'spree_webhooks' }let(:subscriber) { create(:subscriber, :active) }+ let(:webhook_payload_body) { {} }it 'enqueues a HTTP request using Spree::Webhooks::Subscribers::HandleRequest', :job do- expect { described_class.perform_later(body, event, subscriber, 1) }.to have_enqueued_job.on_queue(queue)+ expect { described_class.perform_later(webhook_payload_body, event, subscriber, 1) }.to have_enqueued_job.on_queue(queue)endit 'does not raise if used with the expected arguments', :job doallow(Spree::Webhooks::Subscribers::HandleRequest).to receive_message_chain(:new, :call)- expect { described_class.perform_now(body, event, subscriber) }.not_to raise_error+ expect { described_class.perform_now(webhook_payload_body, event, subscriber) }.not_to raise_errorendenddiff --git a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rbindex 26f5f77bb5..fb6b1ecbe3 100644--- a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb+++ b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb@@ -45,9 +45,10 @@ describe Spree::Webhooks::HasWebhooks doendcontext 'without DISABLE_SPREE_WEBHOOKS' do- let(:body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }context 'after_create_commit' do+ let(:event_name) { 'product.create' }it { expect { product.save }.to emit_webhook_event('product.create') }end@@ -64,7 +65,7 @@ describe Spree::Webhooks::HasWebhooks doendcontext 'with a class name with multiple words' do- let(:body) { Spree::Api::V2::Platform::CmsPageSerializer.new(cms_page).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::CmsPageSerializer.new(cms_page).serializable_hash }let(:cms_page) { create(:cms_homepage, store: store, locale: 'en') }let(:event_name) { 'cms_page.create' }diff --git a/api/spec/models/spree/api/webhooks/order_decorator_spec.rb b/api/spec/models/spree/api/webhooks/order_decorator_spec.rbindex 102fd5b07a..70a602d5a9 100644--- a/api/spec/models/spree/api/webhooks/order_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/order_decorator_spec.rb@@ -2,7 +2,7 @@ require 'spec_helper'describe Spree::Api::Webhooks::OrderDecorator dolet(:store) { create(:store, default: true) }- let(:body) { Spree::Api::V2::Platform::OrderSerializer.new(order).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::OrderSerializer.new(order).serializable_hash }describe 'order.canceled' dodescribe 'completed -> canceled' dodiff --git a/api/spec/models/spree/api/webhooks/payment_decorator_spec.rb b/api/spec/models/spree/api/webhooks/payment_decorator_spec.rbindex 2126a1f170..c271ced7fd 100644--- a/api/spec/models/spree/api/webhooks/payment_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/payment_decorator_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'describe Spree::Api::Webhooks::PaymentDecorator do- let(:body) { Spree::Api::V2::Platform::PaymentSerializer.new(payment).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::PaymentSerializer.new(payment).serializable_hash }let(:payment) { create(:payment) }before { allow(payment).to receive_message_chain(:state_changes, :create!) }@@ -55,7 +55,7 @@ describe Spree::Api::Webhooks::PaymentDecorator dodescribe 'order.paid' dosubject { Timecop.freeze { another_payment.complete } }- let(:body) { Spree::Api::V2::Platform::OrderSerializer.new(order).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::OrderSerializer.new(order).serializable_hash }let(:order) { payment.order }let(:event_name) { 'order.paid' }let!(:another_payment) { create(:payment, order: order) }diff --git a/api/spec/models/spree/api/webhooks/product_decorator_spec.rb b/api/spec/models/spree/api/webhooks/product_decorator_spec.rbindex ae05c9b907..249f73ce73 100644--- a/api/spec/models/spree/api/webhooks/product_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/product_decorator_spec.rb@@ -4,7 +4,7 @@ describe Spree::Api::Webhooks::ProductDecorator dolet(:product) { create(:product) }context 'emitting product.discontinued' do- let(:body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }let(:event_name) { 'product.discontinued' }context 'when product discontinued_on changes' dodiff --git a/api/spec/models/spree/api/webhooks/shipment_decorator_spec.rb b/api/spec/models/spree/api/webhooks/shipment_decorator_spec.rbindex d2b2aff161..356e81ffbc 100644--- a/api/spec/models/spree/api/webhooks/shipment_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/shipment_decorator_spec.rb@@ -13,7 +13,7 @@ describe Spree::Api::Webhooks::ShipmentDecorator doendcontext 'emitting shipment.shipped' do- let(:body) { Spree::Api::V2::Platform::ShipmentSerializer.new(shipment).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::ShipmentSerializer.new(shipment).serializable_hash }let(:event_name) { 'shipment.shipped' }context 'ready -> ship' do@@ -36,7 +36,7 @@ describe Spree::Api::Webhooks::ShipmentDecorator doendcontext 'emitting order.shipped' do- let(:body) { Spree::Api::V2::Platform::OrderSerializer.new(order.reload).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::OrderSerializer.new(order.reload).serializable_hash }let(:event_name) { 'order.shipped' }let!(:shipments) docreate_list(diff --git a/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb b/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rbindex 2565e77aea..9fb66f862d 100644--- a/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'describe Spree::Api::Webhooks::StockItemDecorator do- let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }let(:variant) { create(:variant) }let(:stock_item) { variant.stock_items.first }let(:stock_location) { variant.stock_locations.first }@@ -9,7 +9,7 @@ describe Spree::Api::Webhooks::StockItemDecorator dodescribe 'emitting product.backorderable' dosubject { stock_item.update(backorderable: backorderable) }- let(:body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }let(:product) { variant.product }let(:event_name) { 'product.backorderable' }let!(:variant2) { create(:variant, product: product) }diff --git a/api/spec/models/spree/api/webhooks/stock_movement_decorator_spec.rb b/api/spec/models/spree/api/webhooks/stock_movement_decorator_spec.rbindex 892bbf3156..9eaa622bd3 100644--- a/api/spec/models/spree/api/webhooks/stock_movement_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/stock_movement_decorator_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'describe Spree::Api::Webhooks::StockMovementDecorator do- let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant.reload).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::VariantSerializer.new(variant.reload).serializable_hash }let(:stock_item) { create(:stock_item) }let(:stock_location) { variant.stock_locations.first }@@ -10,7 +10,7 @@ describe Spree::Api::Webhooks::StockMovementDecorator dolet!(:product) { create(:product, stores: [store]) }let!(:variant) { create(:variant, product: product) }let!(:variant2) { create(:variant, product: product) }- let(:body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::ProductSerializer.new(product).serializable_hash }describe 'emitting product.out_of_stock' dolet(:event_name) { 'product.out_of_stock' }diff --git a/api/spec/models/spree/api/webhooks/variant_decorator_spec.rb b/api/spec/models/spree/api/webhooks/variant_decorator_spec.rbindex d647b79e1c..b262d635c4 100644--- a/api/spec/models/spree/api/webhooks/variant_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/variant_decorator_spec.rb@@ -4,7 +4,7 @@ describe Spree::Api::Webhooks::VariantDecorator dolet(:variant) { create(:variant) }context 'emitting variant.discontinued' do- let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }let(:event_name) { 'variant.discontinued' }context 'when variant discontinued_on changes' dodiff --git a/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb b/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rbindex daef918a56..03ae8f5f4d 100644--- a/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb+++ b/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb@@ -2,9 +2,15 @@ require 'spec_helper'describe Spree::Webhooks::Subscribers::HandleRequest dodescribe '#call' do- subject { described_class.new(body: body, event_name: event_name, subscriber: subscriber) }+ subject do+ described_class.new(+ event_name: event_name,+ subscriber: subscriber,+ webhook_payload_body: webhook_payload_body+ )+ end- let(:body) do+ let(:webhook_payload_body) doSpree::Api::V2::Platform::AddressSerializer.new(resource).serializable_hash.to_jsonendlet(:event_name) { 'order.canceled' }@@ -19,7 +25,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest docontext 'before making the request' dolet(:body_with_event_metadata) do- JSON.parse(body).merge(+ JSON.parse(webhook_payload_body).merge(event_created_at: event.created_at,event_id: event.id,event_type: event.name@@ -31,11 +37,11 @@ describe Spree::Webhooks::Subscribers::HandleRequest doallow(Spree::Webhooks::Subscribers::MakeRequest).to receive(:new).and_call_originalsubject.callmessage_fst = "[SPREE WEBHOOKS] 'order.canceled' sending to 'http://google.com/'"- message_snd = "[SPREE WEBHOOKS] 'order.canceled' body: #{body_with_event_metadata}"+ message_snd = "[SPREE WEBHOOKS] 'order.canceled' webhook_payload_body: #{body_with_event_metadata}"expect(Rails.logger).to have_received(:debug).with(message_fst)expect(Rails.logger).to have_received(:debug).with(message_snd)expect(Spree::Webhooks::Subscribers::MakeRequest).to(- have_received(:new).with(body: body_with_event_metadata, url: url)+ have_received(:new).with(webhook_payload_body: body_with_event_metadata, url: url))end@@ -128,7 +134,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest doendcontext 'full flow' do- let(:body) { Spree::Api::V2::Platform::OrderSerializer.new(order.reload).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::OrderSerializer.new(order.reload).serializable_hash }let(:event) { Spree::Webhooks::Event.find_by(name: event_name, subscriber_id: subscriber.id, url: url) }let(:event_name) { 'order.placed' }let(:order) { create(:order, email: '[email protected]') }@@ -144,7 +150,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest doexpect(Spree::Webhooks::Subscribers::MakeRequestJob).to(have_been_enqueued.on_queue('spree_webhooks').- with(body.to_json, event_name, subscriber).+ with(webhook_payload_body.to_json, event_name, subscriber).once)end@@ -152,7 +158,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest docontext 'after executing the job' dolet(:body_with_event_metadata) do- body.merge(+ webhook_payload_body.merge(event_created_at: event.created_at, event_id: event.id, event_type: event.name).to_jsonend@@ -162,7 +168,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest doallow(Spree::Webhooks::Subscribers::MakeRequest).to receive(:new).and_call_originalorder.finalize!expect(Spree::Webhooks::Subscribers::MakeRequest).to(- have_received(:new).with(body: body_with_event_metadata, url: url)+ have_received(:new).with(webhook_payload_body: body_with_event_metadata, url: url))endend@@ -174,7 +180,7 @@ describe Spree::Webhooks::Subscribers::HandleRequest dowith_webhooks_enabled doexpect dodescribed_class.new(- body: body,+ webhook_payload_body: webhook_payload_body,event_name: nil, # forces a validation errorsubscriber: subscriber).calldiff --git a/api/spec/services/spree/webhooks/subscribers/make_request_spec.rb b/api/spec/services/spree/webhooks/subscribers/make_request_spec.rbindex e93af7ec5e..e761ea995b 100644--- a/api/spec/services/spree/webhooks/subscribers/make_request_spec.rb+++ b/api/spec/services/spree/webhooks/subscribers/make_request_spec.rb@@ -1,12 +1,12 @@require 'spec_helper'describe Spree::Webhooks::Subscribers::MakeRequest do- let(:body) { { data: [{}] }.to_json }let(:http_double) { instance_double(Net::HTTP) }let(:url) { 'http://google.com/' }+ let(:webhook_payload_body) { { data: [{}] }.to_json }describe '#execution_time' do- subject { described_class.new(body: body, url: url).execution_time }+ subject { described_class.new(webhook_payload_body: webhook_payload_body, url: url).execution_time }before dostub_request(:post, url)@@ -36,7 +36,7 @@ describe Spree::Webhooks::Subscribers::MakeRequest doenddescribe '#failed_request?' do- subject { described_class.new(body: body, url: url).failed_request? }+ subject { described_class.new(webhook_payload_body: webhook_payload_body, url: url).failed_request? }before { stub_request(:post, url) }@@ -52,9 +52,9 @@ describe Spree::Webhooks::Subscribers::MakeRequest dosubjectend- it 'makes a post HTTP request to the given url and body' do+ it 'makes a post HTTP request to the given url and webhook_payload_body' dosubject- expect(WebMock).to have_requested(:post, url).with(body: body, headers: headers).once+ expect(WebMock).to have_requested(:post, url).with(body: webhook_payload_body, headers: headers).onceendend@@ -82,11 +82,11 @@ describe Spree::Webhooks::Subscribers::MakeRequest dosubjectend- it 'makes a post HTTP request to the given url and body' do+ it 'makes a post HTTP request to the given url and webhook_payload_body' doallow(Net::HTTP).to receive(:new).and_return(http)allow(http).to receive(:use_ssl=).with(true)subject- expect(WebMock).to have_requested(:post, url).with(body: body, headers: headers).once+ expect(WebMock).to have_requested(:post, url).with(body: webhook_payload_body, headers: headers).onceendendend@@ -153,7 +153,7 @@ describe Spree::Webhooks::Subscribers::MakeRequest doenddescribe '#response_code' do- subject { described_class.new(body: body, url: url).response_code }+ subject { described_class.new(webhook_payload_body: webhook_payload_body, url: url).response_code }context 'when request raises an Errno::ECONNREFUSED exception' dobefore do@@ -190,7 +190,7 @@ describe Spree::Webhooks::Subscribers::MakeRequest doenddescribe '#success?' do- subject { described_class.new(body: body, url: url) }+ subject { described_class.new(webhook_payload_body: webhook_payload_body, url: url) }context 'when unprocessable_uri? equals true' dobefore { allow(subject).to receive(:unprocessable_uri?).and_return(true) }@@ -218,7 +218,7 @@ describe Spree::Webhooks::Subscribers::MakeRequest doenddescribe '#unprocessable_uri?' do- subject { described_class.new(body: body, url: url) }+ subject { described_class.new(webhook_payload_body: webhook_payload_body, url: url) }before { allow(subject).to receive(:URI).with(url).and_return(uri) }diff --git a/api/spec/services/spree/webhooks/subscribers/queue_requests_spec.rb b/api/spec/services/spree/webhooks/subscribers/queue_requests_spec.rbindex 70007817bf..0d7b41e5f2 100644--- a/api/spec/services/spree/webhooks/subscribers/queue_requests_spec.rb+++ b/api/spec/services/spree/webhooks/subscribers/queue_requests_spec.rb@@ -2,10 +2,10 @@ require 'spec_helper'describe Spree::Webhooks::Subscribers::QueueRequests, :job, :spree_webhooks dodescribe '#call' do- subject { described_class.call(body: body, event_name: event_name) }+ subject { described_class.call(event_name: event_name, webhook_payload_body: webhook_payload_body) }let(:event_name) { 'order.finalize' }- let(:body) { {} }+ let(:webhook_payload_body) { {} }let(:queue) { 'spree_webhooks' }let(:make_request_job) { Spree::Webhooks::Subscribers::MakeRequestJob }@@ -16,7 +16,7 @@ describe Spree::Webhooks::Subscribers::QueueRequests, :job, :spree_webhooks doit doexpect { subject }.to(- have_enqueued_job(make_request_job).with(body, event_name, subscriber).on_queue(queue)+ have_enqueued_job(make_request_job).with(webhook_payload_body, event_name, subscriber).on_queue(queue))endenddiff --git a/api/spec/services/spree/webhooks_spec.rb b/api/spec/services/spree/webhooks_spec.rbindex 4aa3a6213b..a6d8efdb12 100644--- a/api/spec/services/spree/webhooks_spec.rb+++ b/api/spec/services/spree/webhooks_spec.rb@@ -2,7 +2,7 @@ require 'spec_helper'describe Spree::Webhooks dodescribe '#disable_webhooks' do- let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }+ let(:webhook_payload_body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash }let(:event_name) { 'variant.discontinued' }let(:queue_requests) { instance_double(Spree::Webhooks::Subscribers::QueueRequests) }let(:variant) { create(:variant) }@@ -40,7 +40,7 @@ describe Spree::Webhooks doit 'does not emit the event' dodescribed_class.disable_webhooks { variant.discontinue! }- expect(queue_requests).not_to have_received(:call).with(event: event_name, body: body)+ expect(queue_requests).not_to have_received(:call).with(event: event_name, webhook_payload_body: webhook_payload_body)endend@@ -56,7 +56,7 @@ describe Spree::Webhooks dodescribe 'when using #disable_webhooks' doit 'does not emit the event' dodescribed_class.disable_webhooks { variant.discontinue! }- expect(queue_requests).not_to have_received(:call).with(event: event_name, body: body)+ expect(queue_requests).not_to have_received(:call).with(event: event_name, webhook_payload_body: webhook_payload_body)endendend