From 613016a6cfc1214afd4416ec3de0adc49a7fe004 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Mon, 14 Aug 2017 16:35:40 +0200 Subject: [PATCH] Refactor spec using `expect_any_instance` --- spec/controllers/admin/bulk_line_items_controller_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/controllers/admin/bulk_line_items_controller_spec.rb b/spec/controllers/admin/bulk_line_items_controller_spec.rb index 78f33e9cf8..da1f753dce 100644 --- a/spec/controllers/admin/bulk_line_items_controller_spec.rb +++ b/spec/controllers/admin/bulk_line_items_controller_spec.rb @@ -177,8 +177,11 @@ describe Admin::BulkLineItemsController do end it 'applies enterprise fees locking the order with an exclusive row lock' do - expect_any_instance_of(Spree::Order).to receive(:reload).with(lock: true) - expect_any_instance_of(Spree::Order).to receive(:update_distribution_charge!) + allow(Spree::LineItem) + .to receive(:find).with(line_item1.id.to_s).and_return(line_item1) + + expect(line_item1.order).to receive(:reload).with(lock: true) + expect(line_item1.order).to receive(:update_distribution_charge!) spree_put :update, params end