diff --git a/core/lib/generators/solidus/install/app_templates/payment_method/none.rb b/core/lib/generators/solidus/install/app_templates/payment_method/none.rb new file mode 100644 index 00000000000..740503eb56b --- /dev/null +++ b/core/lib/generators/solidus/install/app_templates/payment_method/none.rb @@ -0,0 +1 @@ +# noop diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index 7e04397493f..54a19f853fe 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -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)' @@ -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 @@ -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' @@ -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" @@ -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 diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb index 82cefcc9d72..d0dde963686 100644 --- a/core/lib/spree/testing_support/common_rake.rb +++ b/core/lib/spree/testing_support/common_rake.rb @@ -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", diff --git a/core/spec/generators/solidus/install/install_generator_spec.rb b/core/spec/generators/solidus/install/install_generator_spec.rb index a2e74536a76..a6c45bf0556 100644 --- a/core/spec/generators/solidus/install/install_generator_spec.rb +++ b/core/spec/generators/solidus/install/install_generator_spec.rb @@ -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)