-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Mailer is what is used to provide applcations with Notify emails. This class is used as the parent for new subclasses that provide the application specific emails. Like a module, we have to test this by creating a new TestMailer that inherits from our updated class. The main thing to notice here is that we have to prevent Rails from carrying out the default behaviour of looking for views to provide the parts of the email (the html and plain text content), we do so by calling `mail` with a block that sets the parts to empty object - these are then replaced later with the actual content.
- Loading branch information
Showing
8 changed files
with
297 additions
and
64 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
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 @@ | ||
# frozen_string_literal: true | ||
|
||
class TestMailer < Mail::Notify::Mailer | ||
def test_view_mail | ||
template_id = params[:template_id] | ||
options = params.except(:template_id) | ||
|
||
view_mail(template_id, options) | ||
end | ||
|
||
def test_template_mail | ||
template_id = params[:template_id] | ||
options = params.except(:template_id) | ||
|
||
template_mail(template_id, options) | ||
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
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
spec/support/templates/test_mailer/my_mail_optional_fields.text.erb
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 @@ | ||
This is the body from the mailers view. |
Oops, something went wrong.