From 4df1ae7571acc485211aa8548093d929916f141d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 2 Mar 2023 15:58:46 +0800 Subject: [PATCH] Add Braintree to the installer as a payment method option Closes https://github.com/solidusio/solidus/issues/4749. --- .circleci/config.yml | 8 ++++++++ .../install/app_templates/payment_method/braintree.rb | 5 +++++ core/lib/generators/solidus/install/install_generator.rb | 6 ++++++ .../generators/solidus/install/install_generator_spec.rb | 4 +++- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index f2218d74418..273f17fc5e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -218,6 +218,14 @@ jobs: cd /tmp/my_app bundle list | grep 'solidus_paypal_commerce_platform (1.' + - install_solidus: { flags: "--sample=false --frontend=starter --payment-method=braintree" } + - test_page: { expected_text: "The only eCommerce platform you’ll ever need." } + - run: + name: Ensure the correct Braintree is installed for SSF + command: | + cd /tmp/my_app + bundle list | grep 'solidus_braintree (3.' + - install_solidus: { flags: "--sample=false --frontend=none --authentication=none" } - test_page: { expected_text: "Ruby on Rails" } diff --git a/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb b/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb new file mode 100644 index 00000000000..a3bebb93132 --- /dev/null +++ b/core/lib/generators/solidus/install/app_templates/payment_method/braintree.rb @@ -0,0 +1,5 @@ +unless Bundler.locked_gems.dependencies['solidus_braintree'] + bundle_command 'add solidus_braintree --version "~> 3.0"' +end + +generate 'solidus_braintree:install' diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index b9bdfbfdb6c..fb82b5edb8f 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -42,6 +42,12 @@ class InstallGenerator < Rails::Generators::AppBase description: 'Install `solidus_bolt`', default: false, }, + { + name: 'braintree', + frontends: %w[none starter], + description: 'Install `solidus_braintree`', + default: false, + }, { name: 'none', frontends: %w[none classic starter], diff --git a/core/spec/generators/solidus/install/install_generator_spec.rb b/core/spec/generators/solidus/install/install_generator_spec.rb index 842502ab9de..fe110bdc526 100644 --- a/core/spec/generators/solidus/install/install_generator_spec.rb +++ b/core/spec/generators/solidus/install/install_generator_spec.rb @@ -110,6 +110,7 @@ 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_not include('[braintree]') expect(strip_ansi questions.first[:desc]).to include('[none]') end @@ -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