Skip to content

Commit

Permalink
Fix specs that fail under Rails 5.2.1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kennyadsl committed Aug 24, 2018
1 parent 277067c commit ca82f6a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ca82f6a

Please sign in to comment.