forked from AgileVentures/WebsiteOne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email interceptor (AgileVentures#2363)
* Add email interceptor * Add environment variable intercept_emails * Update unit test for alert_project_creator_about_new_member * Add unit test for delivering_email model method of SandboxEmailInterceptor
- Loading branch information
Showing
7 changed files
with
69 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class SandboxEmailInterceptor | ||
def self.delivering_email(message) | ||
message.to = ENV['USER_EMAIL'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (Rails.env.development? || Rails.env.staging?) and ENV['INTERCEPT_EMAILS'] == 'true' | ||
ActionMailer::Base.register_interceptor(SandboxEmailInterceptor) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe SandboxEmailInterceptor do | ||
describe '#delivering_email' do | ||
before(:each) do | ||
@user1 = FactoryBot.create(:user) | ||
@project = FactoryBot.create(:project, user: @user1) | ||
@user2 = FactoryBot.create(:user) | ||
end | ||
it 'delivers all emails to user when intercept_emails is set to true' do | ||
stub_const('ENV', {'USER_EMAIL' => 'me@ymail.com'}) | ||
mail = Mailer.alert_project_creator_about_new_member(@project, @user2).deliver_now | ||
SandboxEmailInterceptor.delivering_email(mail) | ||
expect(ActionMailer::Base.deliveries[0].to).to include(ENV['USER_EMAIL']) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<body> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | ||
</head> | ||
<body> | ||
<p>Hi Reva Satterfield,<br></p> | ||
<p> | ||
<a href="mailto:leif.kozey@bruen.org">leif.kozey@bruen.org</a> just joined your project Title 1, you can reach out and personally welcome them.<br> | ||
</p> | ||
<p> | ||
You are receiving this email because you registered at <a href="http://www.agileventures.org/">www.agileventures.org</a>. If you wish to be removed from this mailing list, please login at av.org and go to your profile page and edit "Receive site emails" to be unchecked - if you are already logged in go directly to: <a href="http://www.agileventures.org/users/edit">www.agileventures.org/users/edit</a>. | ||
</p> | ||
</body> | ||
</html> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Hi Reva Satterfield, | ||
=========================================================================== | ||
|
||
leif.kozey@bruen.org just joined your project Title 1, you can reach out and personally welcome them. | ||
=========================================================================== | ||
|
||
You are receiving this email because you registered at http://www.agileventures.org. If you wish to be removed from this mailing list, please login at av.org and go to your profile page and edit "Receive site emails" to be unchecked - if you are already logged in go directly to: http://www.agileventures.org/users/edit/. | ||
|
||
|