mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add specs testing that shipments see deleted variants
This commit is contained in:
33
spec/models/spree/shipment_spec.rb
Normal file
33
spec/models/spree/shipment_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Spree::Shipment do
|
||||
describe "manifest" do
|
||||
let!(:product) { create(:product) }
|
||||
let!(:order) { create(:order, distributor: product.supplier) }
|
||||
let!(:deleted_variant) { create(:variant, product: product) }
|
||||
let!(:other_variant) { create(:variant, product: product) }
|
||||
let!(:line_item_for_deleted) { create(:line_item, order: order, variant: deleted_variant) }
|
||||
let!(:line_item_for_other) { create(:line_item, order: order, variant: other_variant) }
|
||||
let!(:shipment) { create(:shipment_with, :shipping_method, order: order) }
|
||||
|
||||
context "when the variant is soft-deleted" do
|
||||
before { deleted_variant.delete }
|
||||
|
||||
it "can still access the variant" do
|
||||
shipment.reload
|
||||
variants = shipment.manifest.map(&:variant).uniq
|
||||
expect(variants.sort_by(&:id)).to eq([deleted_variant, other_variant].sort_by(&:id))
|
||||
end
|
||||
end
|
||||
|
||||
context "when the product is soft-deleted" do
|
||||
before { deleted_variant.product.delete }
|
||||
|
||||
it "can still access the variant" do
|
||||
shipment.reload
|
||||
variants = shipment.manifest.map(&:variant)
|
||||
expect(variants.sort_by(&:id)).to eq([deleted_variant, other_variant].sort_by(&:id))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user