diff --git a/.gitignore b/.gitignore index 160c8ab..409733f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ # Ignore master key for decrypting credentials and more. /config/master.key /config/database.yml +/config/chexpire.yml /public/packs /public/packs-test /node_modules diff --git a/.travis.yml b/.travis.yml index 4bd83fc..48e05b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: before_install: - cp config/database.example.yml config/database.yml + - cp config/chexpire.test.yml config/chexpire.yml install: - bundle install diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c81..1474cb7 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" + default from: Rails.configuration.chexpire.fetch("mailer_default_from") layout "mailer" end diff --git a/config/application.rb b/config/application.rb index d5b5a21..5adecf8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,5 +31,7 @@ module Chexpire end config.time_zone = "Europe/Paris" + + config.chexpire = config_for(:chexpire) end end diff --git a/config/chexpire.example.yml b/config/chexpire.example.yml new file mode 100644 index 0000000..8c74f9e --- /dev/null +++ b/config/chexpire.example.yml @@ -0,0 +1,13 @@ +default: &default + mailer_default_from: "from@example.org" + +production: + <<: *default + host: "example.org" + +development: + <<: *default + host: "chexpire.local" + +# test configuration included in file used by CI services +<%= IO.read Rails.root.join("config", "chexpire.test.yml") %> diff --git a/config/chexpire.test.yml b/config/chexpire.test.yml new file mode 100644 index 0000000..152302f --- /dev/null +++ b/config/chexpire.test.yml @@ -0,0 +1,3 @@ +test: + mailer_default_from: "contact@chexpire.org" + host: "localhost" diff --git a/config/environments/development.rb b/config/environments/development.rb index 4b8cc17..7a6294a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -37,6 +37,8 @@ Rails.application.configure do config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: config.chexpire.fetch("host"), port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index a61ba5d..fe21a0d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -66,6 +66,8 @@ Rails.application.configure do # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { host: config.chexpire.fetch("host") } + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 0a38fd3..77e282b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -38,6 +38,8 @@ Rails.application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + config.action_mailer.default_url_options = { host: config.chexpire.fetch("host"), port: 3000 } + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr