Merge pull request #3251 from consul/mail_intercept
Configurable email interceptor by environment
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -54,6 +54,7 @@ gem 'unicorn', '~> 5.4.1'
|
||||
gem 'whenever', '~> 0.10.0', require: false
|
||||
gem 'globalize', '~> 5.0.0'
|
||||
gem 'globalize-accessors', '~> 0.2.1'
|
||||
gem 'recipient_interceptor', '~> 0.2.0'
|
||||
|
||||
source 'https://rails-assets.org' do
|
||||
gem 'rails-assets-leaflet'
|
||||
|
||||
@@ -356,6 +356,8 @@ GEM
|
||||
rainbow (3.0.0)
|
||||
raindrops (0.19.0)
|
||||
rake (12.3.1)
|
||||
recipient_interceptor (0.2.0)
|
||||
mail
|
||||
redcarpet (3.4.0)
|
||||
referer-parser (0.3.0)
|
||||
request_store (1.3.2)
|
||||
@@ -551,6 +553,7 @@ DEPENDENCIES
|
||||
rails (= 4.2.11)
|
||||
rails-assets-leaflet!
|
||||
rails-assets-markdown-it (~> 8.2.1)!
|
||||
recipient_interceptor (~> 0.2.0)
|
||||
redcarpet (~> 3.4.0)
|
||||
responders (~> 2.4.0)
|
||||
rinku (~> 2.0.2)
|
||||
|
||||
6
config/initializers/recipient_interceptor.rb
Normal file
6
config/initializers/recipient_interceptor.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
recipients = Rails.application.secrets.email_interceptor_recipients
|
||||
|
||||
if recipients.present?
|
||||
interceptor = RecipientInterceptor.new(recipients, subject_prefix: "[#{Rails.env}]")
|
||||
Mail.register_interceptor(interceptor)
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
default: &default
|
||||
secret_key_base: 56792feef405a59b18ea7db57b4777e855103882b926413d4afdfb8c0ea8aa86ea6649da4e729c5f5ae324c0ab9338f789174cf48c544173bc18fdc3b14262e4
|
||||
email_interceptor_recipients: ""
|
||||
|
||||
maps: &maps
|
||||
map_tiles_provider: "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
|
||||
@@ -6,6 +6,24 @@ feature 'Emails' do
|
||||
reset_mailer
|
||||
end
|
||||
|
||||
context "On Staging Environment" do
|
||||
|
||||
scenario "emails are delivered to configured recipient" do
|
||||
interceptor = RecipientInterceptor.new("recipient@consul.dev", subject_prefix: "[staging]")
|
||||
Mail.register_interceptor(interceptor)
|
||||
|
||||
sign_up
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject("[staging] Confirmation instructions")
|
||||
expect(email).to deliver_to("recipient@consul.dev")
|
||||
expect(email).not_to deliver_to("manuela@consul.dev")
|
||||
|
||||
Mail.unregister_interceptor(interceptor)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
scenario "Signup Email" do
|
||||
sign_up
|
||||
|
||||
|
||||
Reference in New Issue
Block a user