From f6f4faf146d6e1e18ec408ddd3632faaaf5972fc Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sun, 27 Sep 2020 00:31:20 +0100 Subject: [PATCH] Move test setup to application.rb Without spree_core, the test environment file loads before the Spree engine is loaded --- config/application.rb | 5 +++++ config/environments/test.rb | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 0dfdf138f4..ad890e0b2e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,6 +23,11 @@ module Openfoodnetwork end end + config.after_initialize do + # We need this here because the test env file loads before the Spree engine is loaded + Spree::Core::Engine.routes.default_url_options[:host] = 'test.host' if Rails.env = 'test' + end + initializer "spree.environment", before: :load_config_initializers do |app| app.config.spree = Spree::Core::Environment.new Spree::Config = app.config.spree.preferences # legacy access diff --git a/config/environments/test.rb b/config/environments/test.rb index f33423acdd..d6ea342589 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -55,4 +55,3 @@ end # Allows us to use _url helpers in Rspec Rails.application.routes.default_url_options[:host] = 'test.host' -Spree::Core::Engine.routes.default_url_options[:host] = 'test.host'