From b813acdab37f799ae821d54797bb2567b03c798f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 23 Nov 2021 18:34:43 +0000 Subject: [PATCH] Tidy up (consolidate) setting of the "domain" in dev and test environments --- .env.development | 2 ++ .env.test | 2 ++ config/application.rb | 2 +- config/environments/test.rb | 3 --- spec/base_spec_helper.rb | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.env.development b/.env.development index 3e3f4202ef..928f5014b2 100644 --- a/.env.development +++ b/.env.development @@ -5,3 +5,5 @@ SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" OFN_REDIS_URL="redis://localhost:6379/1" OFN_REDIS_JOBS_URL="redis://localhost:6379/2" + +SITE_URL="0.0.0.0:3000" diff --git a/.env.test b/.env.test index 6c9d71e9cc..67237f2af2 100644 --- a/.env.test +++ b/.env.test @@ -2,3 +2,5 @@ # Override locally with `.env.test.local` SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +SITE_URL="test.host" diff --git a/config/application.rb b/config/application.rb index c82fc95267..5324392df9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -45,7 +45,7 @@ module Openfoodnetwork 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' + Spree::Core::Engine.routes.default_url_options[:host] = ENV["SITE_URL"] if Rails.env == 'test' end # We reload the routes here diff --git a/config/environments/test.rb b/config/environments/test.rb index ecfc577d48..f85c7aab9e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -52,6 +52,3 @@ Openfoodnetwork::Application.configure do config.active_job.queue_adapter = :test end - -# Allows us to use _url helpers in Rspec -Rails.application.routes.default_url_options[:host] = 'test.host' diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 34e3e51003..7fbba39b47 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -46,7 +46,7 @@ Capybara.configure do |config| end # Override setting in Spree engine: Spree::Core::MailSettings -ActionMailer::Base.default_url_options[:host] = 'test.host' +ActionMailer::Base.default_url_options[:host] = ENV["SITE_URL"] FactoryBot.use_parent_strategy = false