From ca82f6a703199b38769280da77e1d2dee7a4a979 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Thu, 9 Aug 2018 17:17:43 +0200 Subject: [PATCH] Fix specs that fail under Rails 5.2.1 I'm not sure why but previously the association was returning an instance of ActiveRecord::Associations::CollectionProxy that was considered not changed while reloading. Despite that `shipments` call is still returning the same object, they now have a different `object_id` and this could be the root of the problem. I'm not sure if this issue raised up with Rails 5.2.1 or by using the ransack master branch on github. --- core/spec/models/spree/order_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index 744b19b710b..251983882cc 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -379,13 +379,13 @@ def merge!(other_order, user = nil) it "does nothing if any shipments are ready" do shipment = create(:shipment, order: subject, state: "ready") - expect { subject.ensure_updated_shipments }.not_to change { subject.reload.shipments } + expect { subject.ensure_updated_shipments }.not_to change { subject.reload.shipments.pluck(:id) } expect { shipment.reload }.not_to raise_error end it "does nothing if any shipments are shipped" do shipment = create(:shipment, order: subject, state: "shipped") - expect { subject.ensure_updated_shipments }.not_to change { subject.reload.shipments } + expect { subject.ensure_updated_shipments }.not_to change { subject.reload.shipments.pluck(:id) } expect { shipment.reload }.not_to raise_error end end @@ -1102,11 +1102,12 @@ def generate it "raises an error if any shipments are ready" do shipment = create(:shipment, order: subject, state: "ready") + expect { expect { subject.create_proposed_shipments }.to raise_error(Spree::Order::CannotRebuildShipments) - }.not_to change { subject.reload.shipments } + }.not_to change { subject.reload.shipments.pluck(:id) } expect { shipment.reload }.not_to raise_error end @@ -1117,7 +1118,7 @@ def generate expect { subject.create_proposed_shipments }.to raise_error(Spree::Order::CannotRebuildShipments) - }.not_to change { subject.reload.shipments } + }.not_to change { subject.reload.shipments.pluck(:id) } expect { shipment.reload }.not_to raise_error end