From f3347229fbb5c8fa8fdd6bf0a6c8079f5f4e6da1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 30 Mar 2021 20:25:37 +0100 Subject: [PATCH] Add Variant#default_price test coverage for soft-deletion --- spec/models/spree/variant_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 50214cf6b4..239962a655 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -742,4 +742,21 @@ module Spree end end end + + + describe "#default_price" do + let(:variant) { create(:variant) } + let(:default_price) { variant.default_price } + + context "when the default price is soft-deleted" do + it "can access the default price" do + price_id = default_price.id + + default_price.destroy + + expect(variant.reload.default_price).to be_a Spree::Price + expect(variant.default_price.id).to eq price_id + end + end + end end