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
|
# Load Config, start by selecting defaults via current environment
|
||||||
require 'foodsoft_config'
|
require 'foodsoft_config'
|
||||||
FoodsoftConfig.init
|
FoodsoftConfig.init
|
||||||
|
FoodsoftConfig.init_mailing
|
||||||
|
|
|
@ -71,6 +71,12 @@ class FoodsoftConfig
|
||||||
set_missing
|
set_missing
|
||||||
end
|
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.
|
# Set config and database connection for specific foodcoop.
|
||||||
#
|
#
|
||||||
# Only needed in multi coop mode.
|
# Only needed in multi coop mode.
|
||||||
|
@ -225,9 +231,6 @@ class FoodsoftConfig
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_mailing
|
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
|
ActionMailer::Base.default_url_options[:foodcoop] = scope
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ default: &defaults
|
||||||
tax_default: 6.0
|
tax_default: 6.0
|
||||||
email_sender: noreply@minimal.test
|
email_sender: noreply@minimal.test
|
||||||
|
|
||||||
|
host: localhost
|
||||||
|
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -32,6 +32,7 @@ RSpec.configure do |config|
|
||||||
# without messing up tests run after that
|
# without messing up tests run after that
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
FoodsoftConfig.init
|
FoodsoftConfig.init
|
||||||
|
FoodsoftConfig.init_mailing
|
||||||
end
|
end
|
||||||
|
|
||||||
# If true, the base class of anonymous controllers will be inferred
|
# If true, the base class of anonymous controllers will be inferred
|
||||||
|
|
Loading…
Reference in a new issue