Skip to content

Commit

Permalink
Add Braintree to the installer as a payment method option
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmendoza committed Mar 2, 2023
1 parent 2742cab commit 123947d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
unless Bundler.locked_gems.dependencies['solidus_braintree']
version = @selected_frontend == 'classic' ? "--version='~> 1.2'" : "--git='https://github.com/solidusio/solidus_braintree' --branch='master'"
bundle_command "add solidus_braintree #{version}"
end

generate 'solidus_braintree:install'
3 changes: 3 additions & 0 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InstallGenerator < Rails::Generators::AppBase
PAYMENT_METHODS = %w[
paypal
bolt
braintree
none
]

Expand Down Expand Up @@ -322,10 +323,12 @@ def detect_authentication_to_install
def detect_payment_method_to_install
return 'paypal' if Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
return 'bolt' if Bundler.locked_gems.dependencies['solidus_bolt']
return 'braintree' if Bundler.locked_gems.dependencies['solidus_braintree']

payment_methods_hash = {
'paypal' => "- [#{set_color 'paypal', :bold}] Install `solidus_paypal_commerce_platform` (#{set_color :default, :bold}).",
'bolt' => "- [#{set_color 'bolt', :bold}] Install `solidus_bolt`.",
'braintree' => "- [#{set_color 'braintree', :bold}] Install `solidus_braintree`.",
'none' => "- [#{set_color 'none', :bold}] Skip installing a payment method.",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@
generator.prepare_options

expect(questions.size).to eq(1)
expect(questions.first[:limited_to]).to eq(['paypal', 'bolt', 'none'])
expect(questions.first[:limited_to]).to eq(['paypal', 'bolt', 'braintree', 'none'])
expect(questions.first[:default]).to eq('paypal')
expect(strip_ansi questions.first[:desc]).to include('[paypal]')
expect(strip_ansi questions.first[:desc]).to include('[bolt]')
expect(strip_ansi questions.first[:desc]).to include('[braintree]')
expect(strip_ansi questions.first[:desc]).to include('[none]')
end

Expand All @@ -121,10 +122,11 @@
generator.prepare_options

expect(questions.size).to eq(1)
expect(questions.first[:limited_to]).to eq(['paypal', 'none'])
expect(questions.first[:limited_to]).to eq(['paypal', 'braintree', 'none'])
expect(questions.first[:default]).to eq('paypal')
expect(strip_ansi questions.first[:desc]).to include('[paypal]')
expect(strip_ansi questions.first[:desc]).not_to include('[bolt]')
expect(strip_ansi questions.first[:desc]).to include('[braintree]')
expect(strip_ansi questions.first[:desc]).to include('[none]')
end
end
Expand Down

0 comments on commit 123947d

Please sign in to comment.