Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Solidus <= 2.3 #62

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions lib/solidus_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,38 @@ def combined_first_and_last_name_in_address?
end

def new_gateway_code?
first_version_with_new_gateway_code = Gem::Requirement.new('>= 2.3')
first_version_with_new_gateway_code.satisfied_by?(Spree.solidus_gem_version)
ActiveSupport::Deprecation.warn <<-WARN.squish, caller
SolidusSupport.new_gateway_code? is deprecated without replacement and will be removed
in solidus_support 1.0.
WARN

true
end

def payment_source_parent_class
if new_gateway_code?
Spree::PaymentSource
else
Spree::Base
end
elia marked this conversation as resolved.
Show resolved Hide resolved
ActiveSupport::Deprecation.warn <<-WARN.squish, caller
SolidusSupport.payment_source_parent_class is deprecated and will be removed
in solidus_support 1.0. Please use Spree::PaymentSource instead.
WARN

Spree::PaymentSource
end

def payment_method_parent_class(credit_card: false)
if new_gateway_code?
if credit_card
Spree::PaymentMethod::CreditCard
else
Spree::PaymentMethod
end
if credit_card
ActiveSupport::Deprecation.warn <<-WARN.squish, caller
SolidusSupport.payment_method_parent_class(credit_card: true) is deprecated and will be removed
in solidus_support 1.0. Please use Spree::PaymentMethod::CreditCard instead.
WARN

Spree::PaymentMethod::CreditCard
else
Spree::Gateway
ActiveSupport::Deprecation.warn <<-WARN.squish, caller
SolidusSupport.payment_method_parent_class(credit_card: false) is deprecated and will be removed
in solidus_support 1.0. Please use Spree::PaymentMethod instead.
WARN

Spree::PaymentMethod
end
end

Expand Down
23 changes: 3 additions & 20 deletions spec/solidus_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,18 @@
end
end

context 'with Solidus < 2.3' do
let(:solidus_version) { '2.2.1' }

it { is_expected.to eq(Spree::Gateway) }
end

context 'with Solidus >= 2.3' do
context 'with credit_card: false' do
let(:solidus_version) { '2.3.1' }

it { is_expected.to eq(Spree::PaymentMethod) }
end

# rubocop:disable RSpec/NestedGroups
context 'with credit_card: true' do
let(:credit_card) { true }
let(:solidus_version) { '2.3.1' }

context 'with Solidus < 2.3' do
let(:solidus_version) { '2.2.1' }

it { is_expected.to eq(Spree::Gateway) }
end

context 'with Solidus >= 2.3' do
let(:solidus_version) { '2.3.1' }

it { is_expected.to eq(Spree::PaymentMethod::CreditCard) }
end
it { is_expected.to eq(Spree::PaymentMethod::CreditCard) }
end
# rubocop:enable RSpec/NestedGroups
end

describe '.combined_first_and_last_name_in_address?' do
Expand Down