solidusio / solidus_dev_support

A collection of tools for developing Solidus extensions.
MIT License
21 stars 27 forks source link

Set Rails environment to test before invoking extension:test_app task #187

Closed gsmendoza closed 2 years ago

gsmendoza commented 2 years ago

This fixes the following error when running bundle exec rake in SolidusPaypalCommercePlatform:

An error occurred in a `before(:suite)` hook.
Failure/Error: //= link spree/backend/all.js

Sprockets::FileNotFound:
  couldn't find file 'spree/backend/all.js'
  Checked in these paths:
    /home/gsmendoza/repos/solidusio-contrib/solidus_paypal_commerce_platform/spec/dummy/app/assets/config
    /home/gsmendoza/repos/solidusio-contrib/solidus_paypal_commerce_platform/spec/dummy/app/assets/images
    /home/gsmendoza/repos/solidusio-contrib/solidus_paypal_commerce_platform/spec/dummy/app/assets/stylesheets
    /home/gsmendoza/repos/solidusio-contrib/solidus_paypal_commerce_platform/app/assets/javascripts
    /home/gsmendoza/repos/solidusio-contrib/solidus_paypal_commerce_platform/app/assets/stylesheets

Cause

extension:specs, the default rake task of SolidusPaypalCommercePlatform, executes the rake tasks and Ruby methods below in the given order:

The setup_assets method would only install the all.* frontend and backend assets if either

Currently, when we run bundle exec rake in SolidusPaypalCommercePlatform, neither condition is met:

Trigger

This bug surfaced after we applied https://github.com/solidusio/solidus/pull/4251 (Fix: solidus:install adds the frontend assets even if the repo does not have solidus_frontend).

Solution

Considering that the extension:test_app rake task generates the spec/dummy directory, we can assume that it is expected to run under test environment.

Testing

Checklist

mergify[bot] commented 2 years ago

It looks like this PR is missing a label to determine the type of change it introduces. The maintainer should add one of the following labels:

Additionally, the maintainer may also want to add one of the following:

Once the correct labels have been set, simply remove the needs changelog label label from this PR so I can merge it.

gsmendoza commented 2 years ago

Closing this for now. I have just noticed that common:test_app already sets up RAILS_ENV to test, but it's not being picked up by Solidus::InstallGenerator. Will investigate.