-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5595 from louim/bugfix/mailer-defaults-lambda-arity
Make sure Mailer defaults :from and :reply_to are handled correctly
- Loading branch information
Showing
2 changed files
with
35 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
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 |
---|---|---|
|
@@ -17,4 +17,30 @@ def confirmation_instructions(record, token, opts = {}) | |
|
||
assert mail.content_transfer_encoding, "7bit" | ||
end | ||
|
||
test "default values defined as proc with different arity are handled correctly" do | ||
class TestMailerWithDefault < Devise::Mailer | ||
default from: -> { computed_from } | ||
default reply_to: ->(_) { computed_reply_to } | ||
|
||
def confirmation_instructions(record, token, opts = {}) | ||
@token = token | ||
devise_mail(record, :confirmation_instructions, opts) | ||
end | ||
|
||
private | ||
|
||
def computed_from | ||
"[email protected]" | ||
end | ||
|
||
def computed_reply_to | ||
"[email protected]" | ||
end | ||
end | ||
|
||
mail = TestMailerWithDefault.confirmation_instructions(create_user, "confirmation-token") | ||
assert mail.from, "[email protected]" | ||
assert mail.reply_to, "[email protected]" | ||
end | ||
end |