From 58513ed1425645aecf8bdbb0de66b2f0a45d0aa1 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 16 Mar 2022 18:18:55 +0800 Subject: [PATCH] Fix: `extension:test_app` rake task should detect if Solidus engines are available Acceptance criteria ------------------- Given a Solidus extension calls `SolidusSupport.x_available?` in its Install generator to check if the engine is available When the I run `bundle exec rake extension:test_app` Then the `SolidusSupport.x_available?` should return true (since the dummy app installed by `extension:test_app` includes the frontend, backend, and api engines) Bug description --------------- When called within `bundle exec rake extension:test_app`, the install generator of the extension is not able to detect the Solidus engines within the dummy app, and as such, returns nil for any `SolidusSupport.x_available?` call. Cause ----- The `::Generators::InstallGenerator.start` call within the `common:test_app` rake task is not able to detect the Solidus engines that were just installed by the rake task to the spec/dummy directory. Bug fix ------- Use the `bin/rails` executable to install the extension on the dummy app. Possibly related issues ----------------------- https://github.com/solidusio/solidus_support/pull/66 --- core/lib/spree/testing_support/common_rake.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb index 566e2c66a54..a6486182e99 100644 --- a/core/lib/spree/testing_support/common_rake.rb +++ b/core/lib/spree/testing_support/common_rake.rb @@ -22,9 +22,11 @@ sh "bin/rails db:drop db:create db:migrate VERBOSE=false RAILS_ENV=test" begin - require "generators/#{ENV['LIB_NAME']}/install/install_generator" + generator_namespace = "#{ENV['LIB_NAMESPACE']&.underscore || ENV['LIB_NAME']}" + + require "generators/#{generator_namespace}/install/install_generator" puts 'Running extension installation generator...' - "#{ENV['LIB_NAMESPACE'] || ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start(["--auto-run-migrations"]) + sh "bin/rails generate #{generator_namespace}:install --auto-run-migrations" rescue LoadError # No extension generator to run end