diff options
author | luca-landa <lucalanda@hotmail.it> | 2021-02-12 15:06:47 +0100 |
---|---|---|
committer | luca-landa <lucalanda@hotmail.it> | 2021-03-12 09:31:01 +0100 |
commit | d97bba60a4b9e56e549de0fecf7c83b2b6f0a093 (patch) | |
tree | 7cfdfcb38a182e7671762bc9c93180fbcf94081c /spec | |
parent | f99c56615bc625e4507e73bbc727ec6fd8b70d59 (diff) |
Remove variant from subscriptions on soft deletion
Diffstat (limited to 'spec')
-rw-r--r-- | spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
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 |