Skip to content

Commit

Permalink
Add back PayPal as the default payment method in the installer
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 19, 2022
1 parent 733eec7 commit 21c1549
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
unless Bundler.locked_gems.dependencies['solidus_frontend']
say_status :warning, "Support for frontends other than `solidus_frontend` by `solidus_paypal_commerce_platform` is still in progress.", :yellow
end

unless Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
bundle_command 'add solidus_paypal_commerce_platform'
end

generate 'solidus_paypal_commerce_platform:install'
7 changes: 6 additions & 1 deletion core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class InstallGenerator < Rails::Generators::AppBase
]

PAYMENT_METHODS = %w[
paypal
none
]

Expand Down Expand Up @@ -317,13 +318,17 @@ def detect_authentication_to_install
end

def detect_payment_method_to_install
return 'paypal' if Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
options[:payment_method] ||
(options[:auto_accept] && @selected_frontend == 'classic' ? 'paypal' : 'none') ||
(@selected_frontend != 'classic' && 'none') || # bail out if it's not classic
ask_with_description(
default: 'none',
default: 'paypal',
limited_to: PAYMENT_METHODS,
desc: <<~TEXT
Which payment method would you like to use?
- [#{set_color 'paypal', :bold}] Install `solidus_paypal_commerce_platform` (#{set_color :default, :bold}).
- [#{set_color 'none', :bold}] Skip installing a payment method.
TEXT
)
Expand Down
11 changes: 11 additions & 0 deletions core/spec/generators/solidus/install/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
end
end

it 'defaults to "paypal" for payments when frontend is "classic"' do
generator = described_class.new([], ['--auto-accept', '--frontend=classic'])
generator.prepare_options

aggregate_failures do
expect(generator.instance_variable_get(:@selected_frontend)).to eq("classic")
expect(generator.instance_variable_get(:@selected_authentication)).to eq("devise")
expect(generator.instance_variable_get(:@selected_payment_method)).to eq("paypal")
end
end

it 'disables "seeds" and "sample" if "migrate" are disabled' do
generator = described_class.new([], ['--auto-accept', '--migrate=false'])
generator.prepare_options
Expand Down

0 comments on commit 21c1549

Please sign in to comment.