Skip to content

Commit

Permalink
Add back the --payment-method option for solidus:install
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 19, 2022
1 parent d930744 commit 733eec7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# noop
23 changes: 23 additions & 0 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class InstallGenerator < Rails::Generators::AppBase
none
]

PAYMENT_METHODS = %w[
none
]

class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations and seeds must be run)'
Expand All @@ -41,6 +45,7 @@ class InstallGenerator < Rails::Generators::AppBase

class_option :frontend, type: :string, enum: FRONTENDS + LEGACY_FRONTENDS, default: nil, desc: "Indicates which frontend to install."
class_option :authentication, type: :string, enum: AUTHENTICATIONS, default: nil, desc: "Indicates which authentication system to install."
class_option :payment_method, type: :string, enum: PAYMENT_METHODS, default: nil, desc: "Indicates which payment method to install."

# DEPRECATED
class_option :with_authentication, type: :boolean, hide: true, default: nil
Expand All @@ -59,6 +64,7 @@ def prepare_options
@load_sample_data = options[:sample] && @run_migrations && @load_seed_data
@selected_frontend = detect_frontend_to_install
@selected_authentication = detect_authentication_to_install
@selected_payment_method = detect_payment_method_to_install

# Silence verbose output (e.g. Rails migrations will rely on this environment variable)
ENV['VERBOSE'] = 'false'
Expand Down Expand Up @@ -159,6 +165,10 @@ def install_frontend
apply_template_for :frontend, @selected_frontend
end

def install_payment_method
apply_template_for :payment_method, @selected_payment_method
end

def populate_seed_data
if @load_seed_data
say_status :loading, "seed data"
Expand Down Expand Up @@ -305,5 +315,18 @@ def detect_authentication_to_install
TEXT
)
end

def detect_payment_method_to_install
options[:payment_method] ||
ask_with_description(
default: 'none',
limited_to: PAYMENT_METHODS,
desc: <<~TEXT
Which payment method would you like to use?
- [#{set_color 'none', :bold}] Skip installing a payment method.
TEXT
)
end
end
end
1 change: 1 addition & 0 deletions core/lib/spree/testing_support/common_rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def initialize
Dir.pwd, # use the current dir as Rails.root
"--auto-accept",
"--authentication=none",
"--payment-method=none",
"--migrate=false",
"--seed=false",
"--sample=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
aggregate_failures do
expect(generator.instance_variable_get(:@selected_frontend)).to eq("starter")
expect(generator.instance_variable_get(:@selected_authentication)).to eq("devise")
expect(generator.instance_variable_get(:@selected_payment_method)).to eq("none")
expect(generator.instance_variable_get(:@run_migrations)).to eq(true)
expect(generator.instance_variable_get(:@load_seed_data)).to eq(true)
expect(generator.instance_variable_get(:@load_sample_data)).to eq(true)
Expand Down

0 comments on commit 733eec7

Please sign in to comment.