Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Removed deprecated `Spree::CreditCards::Destroy`

Damian Legawiece89ba2be5ce0
diff --git a/spree/core/app/services/spree/credit_cards/destroy.rb b/spree/core/app/services/spree/credit_cards/destroy.rb
deleted file mode 100644
index 4710651231..0000000000
--- a/spree/core/app/services/spree/credit_cards/destroy.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module Spree
- module CreditCards
- # @deprecated Use card.destroy directly instead. Payment cleanup is now
- # handled by the before_destroy callback in Spree::PaymentSourceConcern.
- # This service will be removed in Spree 6.0.
- class Destroy
- prepend Spree::ServiceModule::Base
-
- def call(card:)
- Spree::Deprecation.warn(
- "#{self.class.name} is deprecated and will be removed in Spree 6.0. " \
- 'Use card.destroy directly instead. Payment cleanup is now handled ' \
- 'automatically by the before_destroy callback in PaymentSourceConcern.',
- caller_locations(2)
- )
-
- if card.destroy
- success(card: card)
- else
- failure(card.errors.full_messages.to_sentence)
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/services/spree/credit_cards/destroy_spec.rb b/spree/core/spec/services/spree/credit_cards/destroy_spec.rb
deleted file mode 100644
index 597f12f398..0000000000
--- a/spree/core/spec/services/spree/credit_cards/destroy_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'spec_helper'
-
-describe Spree::CreditCards::Destroy, type: :service do
- subject { described_class.call(card: credit_card) }
-
- let!(:order) { create(:order_with_line_items) }
- let!(:credit_card) { create(:credit_card, user_id: order.user_id) }
-
- before do
- allow(Spree::Deprecation).to receive(:warn)
- end
-
- describe '#call' do
- it 'emits a deprecation warning' do
- subject
-
- expect(Spree::Deprecation).to have_received(:warn).with(/deprecated and will be removed in Spree 6.0/, anything)
- end
-
- it 'still destroys the credit card' do
- subject
-
- expect(credit_card.reload.deleted_at).not_to be_nil
- end
-
- context 'with payments on incomplete orders' do
- let!(:payment) { create(:payment, source: credit_card, order: order) }
- let!(:complete_payment) { create(:payment, source: credit_card, order: order, state: 'completed') }
-
- it 'cleans up payments via the before_destroy callback' do
- res = subject
-
- expect(res.success).to eq true
- expect(payment.reload.state).to eq 'invalid'
- expect(complete_payment.reload.state).to eq 'void'
- expect(credit_card.deleted_at).not_to be_nil
- end
- end
- end
-end