From 46ff247bc987645fd9ca0485a2443497474e5a04 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:27:05 +0000 Subject: [PATCH] Ensure ShippingMethod#destroy is using soft-deletion https://github.com/spree/spree/commit/25f5c2daf82d64d04fb77dd99e63aa941eae52f8 We've already applied some of the changes in this commit during previous Spree upgrade work, but there were a couple of bits missing. --- app/models/spree/shipping_method.rb | 1 + spec/models/spree/shipping_method_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/app/models/spree/shipping_method.rb b/app/models/spree/shipping_method.rb index 12c241bd76..ece1af7a61 100644 --- a/app/models/spree/shipping_method.rb +++ b/app/models/spree/shipping_method.rb @@ -5,6 +5,7 @@ module Spree include Spree::Core::CalculatedAdjustments DISPLAY = [:both, :front_end, :back_end].freeze + acts_as_paranoid acts_as_taggable default_scope -> { where(deleted_at: nil) } diff --git a/spec/models/spree/shipping_method_spec.rb b/spec/models/spree/shipping_method_spec.rb index b69e4f5fb4..35ecfa6d83 100644 --- a/spec/models/spree/shipping_method_spec.rb +++ b/spec/models/spree/shipping_method_spec.rb @@ -159,6 +159,16 @@ module Spree end end + # Regression test for Spree #4320 + context "soft deletion" do + let(:shipping_method) { create(:shipping_method) } + + it "soft-deletes when destroy is called" do + shipping_method.destroy + expect(shipping_method.deleted_at).to_not be_blank + end + end + context 'factory' do let(:shipping_method){ create :shipping_method }