Skip to content

Commit

Permalink
Remove support for Solidus <= 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Apr 16, 2021
1 parent 2eb354a commit 7d73dfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
21 changes: 4 additions & 17 deletions lib/solidus_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,15 @@ def combined_first_and_last_name_in_address?
Spree::Config.use_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)
end

def payment_source_parent_class
if new_gateway_code?
Spree::PaymentSource
else
Spree::Base
end
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
Spree::PaymentMethod::CreditCard
else
Spree::Gateway
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

0 comments on commit 7d73dfd

Please sign in to comment.