Set the common ActionMailer default_url_options only once
There is no need to set options other than the foodcoop during every change of the scope. This also makes sure that the correct options will be loaded during testing to fix problems with newer rails versions.
This commit is contained in:
parent
722bb474d1
commit
91eeac6c40
4 changed files with 10 additions and 3 deletions
|
@ -3,3 +3,4 @@
|
|||
# Load Config, start by selecting defaults via current environment
|
||||
require 'foodsoft_config'
|
||||
FoodsoftConfig.init
|
||||
FoodsoftConfig.init_mailing
|
||||
|
|
|
@ -71,6 +71,12 @@ class FoodsoftConfig
|
|||
set_missing
|
||||
end
|
||||
|
||||
def init_mailing
|
||||
[:protocol, :host, :port, :script_name].each do |k|
|
||||
ActionMailer::Base.default_url_options[k] = self[k] if self[k]
|
||||
end
|
||||
end
|
||||
|
||||
# Set config and database connection for specific foodcoop.
|
||||
#
|
||||
# Only needed in multi coop mode.
|
||||
|
@ -225,9 +231,6 @@ class FoodsoftConfig
|
|||
end
|
||||
|
||||
def setup_mailing
|
||||
[:protocol, :host, :port, :script_name].each do |k|
|
||||
ActionMailer::Base.default_url_options[k] = self[k] if self[k]
|
||||
end
|
||||
ActionMailer::Base.default_url_options[:foodcoop] = scope
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ default: &defaults
|
|||
tax_default: 6.0
|
||||
email_sender: noreply@minimal.test
|
||||
|
||||
host: localhost
|
||||
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
|
|
@ -32,6 +32,7 @@ RSpec.configure do |config|
|
|||
# without messing up tests run after that
|
||||
config.before(:each) do
|
||||
FoodsoftConfig.init
|
||||
FoodsoftConfig.init_mailing
|
||||
end
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
|
|
Loading…
Reference in a new issue