Set default URL host

Setting the default host resolves:

    Missing host to link to! Please provide the :host parameter, set
    default_url_options[:host], or set :only_path to true

Configuring RSpec to use the default host resolves:

    Expected response to be a redirect to <http://test.host/…>
    but was a redirect to <http://localhost/…>.
This commit is contained in:
Andrew Kvalheim 2022-10-27 12:54:35 -07:00
parent 097470bb0c
commit 5b89f64eaf
4 changed files with 21 additions and 5 deletions

View file

@ -73,7 +73,12 @@ Rails.application.configure do
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.action_mailer.default_url_options = { host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000') }
# Provide a default host for URLs
Rails.application.routes.default_url_options[:host] = ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')
config.action_controller.default_url_options = Rails.application.routes.default_url_options
config.action_mailer.default_url_options = Rails.application.routes.default_url_options
# Configure outgoing mail
config.action_mailer.smtp_settings = {
address: ENV.fetch('OSEM_SMTP_ADDRESS', 'localhost'),
port: ENV.fetch('OSEM_SMTP_PORT', 25),