Allow from address to fall back to parent mailer #187
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm in a situation where I want the parent mailer class to set the
from
address.The use case is that based on the
I18n.locale
we set a different from address/domain.Right now it's not possible to do this, as even with
nil
fordefault_from_address
it will not fall back to the parent (the mailer will fail: ArgumentError (SMTP From address may not be blank)). That basically means only one, fixed from address is supported.I've come up with a small PR that makes that work by not setting the default value if it's nil.
Curious to hear what you think, I'm not entirely sure about:
mailer_defaults
method? Feel like it could also live in thePasswordless::Mailer
class.I've had some issues with getting all tests to run, not sure if this is correct now. Since we need to change the config just for this test, I think setting it like this and resetting at the end is the best way to do it.edit: found theWithConfig.with_config
helper that solves my problem 😊Happy to take it in the direction you want with some pointers 😁