ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.71k stars 236 forks source link

Allow launchy = false to prevent letter opener from opening emails #172

Closed bradrees closed 4 years ago

bradrees commented 4 years ago

Pull Request

Issue

https://github.com/ryanb/letter_opener/issues/117

Description

Provide the option to disable the opening of generated emails.

This change is useful during DB seed to prevent hundreds of emails being opened when you have a reasonably sized application with comprehensive seeds that cover common use cases.

This was originally authored by AmpleOrganics, and we have found it very useful, so are creating a PR to merge into main, as there is an outstanding issue that was not resolved. https://github.com/AmpleOrganics/letter_opener/commit/e5eddd9a418da0ea60b4ba3b04630ac4e64aa088

PR Type

What kind of change does this PR introduce?

How Has This Been Tested?

nashby commented 4 years ago

Hey @bradrees! Thank you for PR but I think proposed options in #117 are good enough to make it work for seeds.

bradrees commented 4 years ago

I'm not sure I agree - creating a new environment is quite a big change, and breaks things like Rails.env.development?, which I know is an anti-pattern, but it still useful in a dev environment. It also doesn't allow us to disable and re-enable within the same process.

I do feel that having the basic option of a simple on/off switch is beneficial in a number of ways, and I'm clearly not the only one, as there are already outstanding issues and forks from others.

It's not like the PR is complex either, it's a boolean accessor and an if statement.