Remove fire_event method usage

This commit is contained in:
Arun Kumar Mohan
2020-10-01 19:57:27 -05:00
parent 4cd645b60e
commit b0fa1464f8
5 changed files with 1 additions and 32 deletions

View File

@@ -47,8 +47,6 @@ class CheckoutController < Spree::StoreController
params_adapter = Checkout::FormDataAdapter.new(permitted_params, @order, spree_current_user)
return action_failed unless @order.update(params_adapter.params[:order])
fire_event('spree.checkout.update')
checkout_workflow(params_adapter.shipping_method_id)
rescue Spree::Core::GatewayError => e
rescue_from_spree_gateway_error(e)

View File

@@ -78,11 +78,7 @@ module Spree
discard_empty_line_items
with_open_adjustments { update_totals_and_taxes }
if @order == current_order
fire_event('spree.order.contents_changed')
else
@order.update_distribution_charge!
end
@order.update_distribution_charge!
respond_with(@order) do |format|
format.html do

View File

@@ -6,11 +6,6 @@ require 'open_food_network/feature_toggle'
require 'open_food_network/tag_rule_applicator'
require 'concerns/order_shipment'
ActiveSupport::Notifications
.subscribe('spree.order.contents_changed') do |_name, _start, _finish, _id, payload|
payload[:order].reload.update_distribution_charge!
end
module Spree
class Order < ActiveRecord::Base
prepend OrderShipment

View File

@@ -16,20 +16,6 @@ module Spree
protected
# Convenience method for firing instrumentation events with the default payload hash
def fire_event(name, extra_payload = {})
ActiveSupport::Notifications.instrument(name, default_notification_payload.
merge(extra_payload))
end
# Creates the hash that is sent as the payload for all notifications.
# Specific notifications will add additional keys as appropriate.
# This method can be overriden to provide additional data when
# responding to a notification
def default_notification_payload
{ user: spree_current_user, order: current_order }
end
# This can be used in views as well as controllers.
# e.g. <% self.title = 'This is a custom title for this view' %>
attr_writer :title

View File

@@ -48,12 +48,6 @@ describe CheckoutController, concurrency: true, type: :controller do
# New threads start running straight away. The breakpoint is after loading
# the order and before advancing the order's state and making payments.
breakpoint.lock
expect(controller).to receive(:fire_event).with("spree.checkout.update") do
breakpoint.synchronize {}
# This is what fire_event does.
# I did not find out how to call the original code otherwise.
ActiveSupport::Notifications.instrument("spree.checkout.update")
end
# Starting two checkout threads. The controller code will determine if
# these two threads are synchronised correctly or run into a race condition.