From d97bba60a4b9e56e549de0fecf7c83b2b6f0a093 Mon Sep 17 00:00:00 2001 From: luca-landa Date: Fri, 12 Feb 2021 15:06:47 +0100 Subject: Remove variant from subscriptions on soft deletion --- .../variant/auto_delete_from_subscriptions_spec.rb | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb (limited to 'spec') diff --git a/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb new file mode 100644 index 0000000..422e992 --- /dev/null +++ b/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +RSpec.describe SolidusSubscriptions::Spree::Variant::AutoDeleteFromSubscriptions, type: :model do + subject { create(:variant, subscribable: true) } + + describe '.discard' do + it 'deletes itself from subscriptions' do + subscription = create(:subscription) + create(:subscription_line_item, subscription: subscription, subscribable: subject) + + expect { subject.discard }.to change { SolidusSubscriptions::LineItem.count }.by(-1) + end + end + + describe '.destroy' do + it 'deletes itself from subscriptions' do + subscription = create(:subscription) + create(:subscription_line_item, subscription: subscription, subscribable: subject) + + expect { subject.destroy }.to change { SolidusSubscriptions::LineItem.count }.by(-1) + end + end +end -- cgit v1.2.3