From c7359155ecb318c588f6ffe4a384040cbe60ac03 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Fri, 20 Sep 2019 14:50:07 +0200 Subject: [PATCH] Remove duplicate Spree::Order.register_update_hook specs --- core/spec/models/spree/order/updating_spec.rb | 18 --------------- core/spec/models/spree/order_spec.rb | 23 +++++++------------ 2 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 core/spec/models/spree/order/updating_spec.rb diff --git a/core/spec/models/spree/order/updating_spec.rb b/core/spec/models/spree/order/updating_spec.rb deleted file mode 100644 index 0fc840216f8..00000000000 --- a/core/spec/models/spree/order/updating_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Spree::Order, type: :model do - let(:order) { create(:order) } - - context "#update!" do - context "when there are update hooks", partial_double_verification: false do - before { Spree::Order.register_update_hook :foo } - after { Spree::Order.update_hooks.clear } - it "should call each of the update hooks" do - expect(order).to receive :foo - order.recalculate - end - end - end -end diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index 1f8c346fe5a..b8ca370ccc7 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -366,26 +366,19 @@ def merge!(other_order, user = nil) end end - context "add_update_hook", partial_double_verification: false do - before do - Spree::Order.class_eval do - register_update_hook :add_awesome_sauce - end - end + context ".register_update_hook", partial_double_verification: false do + let(:order) { create(:order) } - after do - Spree::Order.update_hooks = Set.new - end + before { Spree::Order.register_update_hook :foo } + after { Spree::Order.update_hooks.clear } - it "calls hook during update" do - order = create(:order) - expect(order).to receive(:add_awesome_sauce) + it "calls hooks during #recalculate" do + expect(order).to receive :foo order.recalculate end - it "calls hook during finalize" do - order = create(:order) - expect(order).to receive(:add_awesome_sauce) + it "calls hook during #finalize!" do + expect(order).to receive :foo order.finalize! end end