Commit Graph

1723 Commits

Author SHA1 Message Date
Rafael Mendonça França
0b95524ac8
Merge PR #47520 2023-02-28 19:13:45 +00:00
Rafael Mendonça França
c3a288b35b
Copy edits on latest patch 2023-02-28 19:13:31 +00:00
Andrew Novoselac
f2cacd5d11 Added deliver_enqueued_emails to ActionMailer::TestHelper. This method delivers all enqueued email jobs.
Example:

```ruby
def test_deliver_enqueued_emails
  deliver_enqueued_emails do
    ContactMailer.welcome.deliver_later
    end
  assert_emails 1
end
```
2023-02-28 14:07:42 -05:00
Jeffrey Hardy
4d2eeafa70 Update Action Mailer's deliver_later_queue_name documentation with current defaults
Since Rails 6.1, the default configuration has been to use Active Job's default
queue, achieved by setting the queue name to `nil`.

Refs:
- https://github.com/rails/rails/pull/47408
- https://github.com/rails/rails/pull/47408#discussion_r1118672914
2023-02-27 12:42:14 -05:00
zzak
d2af670dba
Remove Copyright years (#47467)
* Remove Copyright years

* Basecamp is now 37signals... again

Co-authored-by: David Heinemeier Hansson <dhh@hey.com>

---------

Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
2023-02-23 11:38:16 +01:00
Jeffrey Hardy
fa17c9ac99 Allow mailer classes to customize the deliver_later queue name
The `deliver_later_queue_name` is already configurable on ActionMailer::Base,
however the value is inherited by all subclasses. Use a class-inheritable
attribute instead, so that subclasses can override.

Refs:
- https://github.com/rails/rails/pull/18587#issuecomment-324975192
2023-02-15 13:31:12 -05:00
Yasuo Honda
f838a74212
Merge pull request #46866 from ghousemohamed/change-year-2022-to-2023 2023-02-13 13:15:43 +09:00
zzak
b3d64e0112
🌶️ Spice up new Mailer preview for all headers 2023-02-09 14:50:47 +09:00
Guillermo Iguaran
6ba2e90bd3
Merge branch 'main' into matt/show-all-headers-email-preview 2023-02-08 11:03:25 -08:00
Matt Swanson
449d92dc2b Added option to show all headers for mailer previews 2023-02-08 11:00:51 -05:00
zzak
f8544410a2 Use stable guides link for package READMEs
E.g.: These show up here:
https://api.rubyonrails.org/files/actioncable/README_md.html
2023-02-04 09:01:00 +09:00
Sean Doyle
6fea9a09f2 Gracefully degrade when ActionMailer::Base#params is nil
Prior to this change, access to `params` on `ActionMailer::Base`
instances prior to being decorated by `ActionMailer::Parameterized.with`
calls results in a `NoMethodError`:

```
Error:
ParameterizedTest#test_degrade_gracefully_when_.with_is_not_called:
NoMethodError: undefined method `[]' for nil:NilClass

  before_action { @inviter, @invitee = params[:inviter], params[:invitee] }
                                             ^^^^^^^^^^
```

This change modifies the `attr_accessor :params` to be an `attr_writer`
paired with a `params` method that assigns `@params` to an empty `Hash`
whenever it's accessed without being otherwise initialized.
2023-01-21 12:04:43 -05:00
Alex Ghiculescu
a3724cdd20 assert_emails: return the emails that were sent
This pattern is pretty common:

```ruby
assert_emails 1 do
  post invite_user_path # ...
end
email = ActionMailer::Base.deliveries.last
assert_equal "You were invited!", email.subject
```

We can make it a bit nicer, by returning the email object from `assert_emails`. This is similar to how `assert_raises` returns the error so you can do additional checks on it. With this PR:

```ruby
email = assert_emails 1 do
  post invite_user_path # ...
end
assert_equal "You were invited!", email.subject
```

If a single email is sent, a single `Mail::Message` is returned. If multiple emails were sent, an array is returned.

```ruby
emails = assert_emails 2 do
  post invite_user_path # ...
end
emails.each do |email|
  assert_equal "You were invited!", email.subject
end
```
2023-01-16 12:44:32 -07:00
Jonathan Hefner
cfe300ceb1 Format inline code [ci-skip] 2023-01-08 15:47:20 -06:00
Jonathan Hefner
3eadf057db Fix typos in API docs [ci-skip] 2023-01-08 15:47:20 -06:00
Ghouse Mohamed
e0559d2c1c Change 2022 -> 2023 2023-01-03 13:22:00 +05:30
Andy
0398459e9a Change sendmail default options to match Mail 2.8.x arguments format.
The Mail gem changed format of the delivery method arguments for
sendmail from a string to an array of strings in this commit
7e1196bd29

As the settings are now a sendmail delivery method produces the
following error:
```
.../mail-2.8.0/lib/mail/network/delivery_methods/sendmail.rb:53:in `initialize': :arguments expected to be an Array of individual string args (ArgumentError)
```

This also updates the mail dependency since the new default won't work
with the older versions.
2022-12-06 20:41:09 -05:00
Étienne Barrié
3d6a7b2faa Initialize deprecators before configuring them
Since engine initializers run later in the process, we need to run this
initializer earlier than the default.

This ensures they're all registered before the environments are loaded.
2022-11-28 10:47:26 +01:00
Jonathan Hefner
b3a2bb326c Add ActionMailer.deprecator
This commit adds `ActionMailer.deprecator` and replaces all usages of
`ActiveSupport::Deprecation.warn` in `actionmailer/lib` with
`ActionMailer.deprecator`.

Additionally, this commit adds `ActionMailer.deprecator` to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
2022-10-29 16:01:02 -05:00
Jonathan Hefner
48d4e6e02b Add ActionDispatch.deprecator
This commit adds `ActionDispatch.deprecator` and replaces all usages of
`ActiveSupport::Deprecation.warn` in `actionpack/lib/action_dispatch`
with `ActionDispatch.deprecator`.

Additionally, this commit adds `ActionDispatch.deprecator` to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
2022-10-27 17:11:02 -05:00
Jean Boussier
d917896f45 Enable verbose mode in test and report warnings as errors
We recently let a few very easy to avoid warnings get merged.
The root cause is that locally the test suite doesn't run in
verbose mode unless you explictly pass `-w`.

On CI warnings are enabled, but there is no reason to look at the
build output unless something is failing. And even if one wanted
to do that, that would be particularly work intensive since warnings
may be specific to a Ruby version etc.

Because of this I believe we should:

  - Always run the test suite with warnings enabled.
  - Raise an error if a warning is unexpected.

We've been using this pattern for a long time at Shopify both in private
and public repositories.
2022-10-11 09:25:18 +02:00
John Bampton
2f699c51ce Fix word case. html -> HTML 2022-09-18 04:21:22 +10:00
Yasuo Honda
349a66ebed Drop Rubinius code
Rubinius has not been maintained since May 2020 and based on the
discussion at https://github.com/rails/rails/pull/44984 ,
I think we can remove Rubinius specific code from Rails.
2022-09-15 23:43:51 +09:00
Igor Kasyanchuk
9f0a064fde
Added ability to download .eml file for the email preview. 2022-09-10 00:05:32 +03:00
Christian Schmidt
89fdd5e34e
Recommend mandatory STARTTLS for Google (#43594)
* Recommend mandatory STARTTLS

* Explain version constraints
2022-09-09 16:00:07 -04:00
Jean Boussier
bd19d1baf1 Optimize AS::LogSubscriber
The various LogSubscriber subclasses tend to subscribe to events
but then end up doing nothing if the log level is high enough.

But even if we end up not logging, we have to go through the
entire notification path, record timing etc.

By allowing subscribers to dynamically bail out early, we can
save a lot of work if all subscribers are silenced.
2022-08-12 09:58:17 +02:00
Rafael Mendonça França
95066e5fbd
Merge pull request #31595 from fatkodima/mailer-preview_paths
Support multiple preview paths for mailers
2022-08-09 16:20:18 -03:00
Tom Rossi
22a0692a59
Improvements to assert_enqueued_email_with (#45752)
* This is an attempt to make the assert_enqueued_email_with easier to implement.

* Update actionmailer/test/test_helper_test.rb

Fix spelling.

* Documenting additional tests

* Missing a closing "end"

* Renaming tests for consistency

* Updating name

* Naming and documentation

* Leaving original test unchanged

* Fix test name, add new test

* Add assert_enqueued_emails examples to Rails guide

* Add example to test_helper

* Tweaking the Rails guide (#3)

* Updating Rails guide for consistency.

Co-authored-by: Bry <bryan.hunt@hey.com>
Co-authored-by: Ron Shinall <81988008+ron-shinall@users.noreply.github.com>
2022-08-09 14:16:19 +02:00
Jean Boussier
fc0db35fb1 Add OutputBuffer#raw and #capture to reduce the need to swap the buffer
Right now many helpers have to deal with two modes of operation to
capture view output.

The main one is to swap the `@output_buffer` variable with a new buffer.
But since some view implementations such as `builder` keep a reference
on the buffer they were initialized with, this doesn't always work.

So additionally, the various capturing helpers also record the buffer
length prior to executing the block, and then `slice!` the buffer back
to its original size.

This is wasteful and make the code rather unclear.

Now that `OutputBuffer` is a delegator, I'd like to refactor all this
so that:

  - @output_buffer is no longer re-assigned
  - A single OutputBuffer instance is used for the entire response rendering
  - Instead capturing is done through `OutputBuffer#capture`

Once the above is achieved, it should allow us to enabled Erubi's
`:chain_appends` option and get some reduced template size and some
performance.

Not re-assigning `@output_buffer` will also allow template to access
the local variable instead of an instance variable, which is cheaper.

But more importantly, that should make the code easier to understand
and easier to be compatible with `StreamingBuffer`.
2022-08-03 12:56:34 +02:00
fatkodima
64ad045e47 Support multiple preview paths for mailers 2022-06-30 15:09:59 +03:00
Gannon McGibbon
0965560353 Improve mailer generator usage docs
- Makes heading styles consistent with other generators
- Adds backticks to code snippets
- Adds more examples
2022-06-21 00:30:27 -05:00
Jonathan Hefner
e4ec2cbb49
Merge pull request #44777 from jean-francois-labbe/main
Document action mailer rescue_from [ci-skip]
2022-05-03 10:47:38 -05:00
jean-francois labbe
f00151ab78 Document action mailer rescue_from
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2022-05-03 08:59:56 +02:00
Ryuta Kamizono
714fd07fd9 All intermediate delegation methods should preserve kwargs flag
Since 0456826180,
`foo(*caller_args)` method call delegation no longer preserve kwargs
flag.

Fixes #44846.
2022-04-06 15:32:54 +09:00
André Luis Leal Cardoso Junior
921263bb92 Only configure smtp_settings if provided on configuration 2022-03-15 22:31:04 -03:00
Ghouse Mohamed
6ee6cb554b Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
Jean Boussier
2fd34270eb Eager load controllers view_context_class
These classes are relatively small, however they include lots of
modules as helpers. And if any of the included module hold constants
including it cause the global constant cache to be invalidated
which is really bad for performance.

So when eager loading is enabled we create all the possible classes
as part of the application boot.
2022-03-02 08:47:54 +01:00
Eileen M. Uchitelle
be4b9057bb
Merge pull request #44504 from sanjioh/fix-typos
Fix some typos
2022-02-23 16:58:06 -05:00
Jonathan Hefner
a199aaedb8 Cross-link API docs [ci-skip]
RDoc will automatically format and link API references as long as they
are not already marked up as inline code.

This commit removes markup from various API references so that those
references will link to the relevant API docs.
2022-02-21 11:45:25 -06:00
Jonathan Hefner
e37adfed4e Add Oxford commas [ci-skip] 2022-02-21 11:11:11 -06:00
Fabio Sangiovanni
6e30c183b6 Fix some typos. 2022-02-21 17:58:23 +01:00
Aleksandar N. Kostadinov
f1a770c798
document usage of :enable_starttls 2022-01-06 17:41:00 +02:00
Rafael Mendonça França
5dd292f551
Temporarily add net-gems as dependencies of frameworks that use mail
In Ruby 3.1 those gems were dropped from the stdlib, so they need to be
explicitly installed. Mail should be doing this for us, but since it
cares about Ruby < 2.6, and those gems can't be installed there, they
can't add them to the gemspec without dropping support to old rubies.

Since we don't care about Ruby < 2.7, we can just require them in all
frameworks that use mail.
2022-01-05 17:42:40 +00:00
André Luis Leal Cardoso Junior
02b7854db5 Keep configuration of smtp_settings consistent between 6.1 and 7.0 2022-01-03 23:53:40 -03:00
Ryuta Kamizono
65766ebcc8 Bump license years to 2022 [ci-skip] 2022-01-01 15:22:15 +09:00
Rafael Mendonça França
83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rafael Mendonça França
ddc7fb6e6e
Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob 2021-11-17 21:51:11 +00:00
Rafael Mendonça França
1fde031e89 Fix gemspec 2021-11-15 21:06:21 +00:00
Rafael Mendonça França
9195b7fd0a
Require MFA to release rails 2021-11-15 20:37:42 +00:00
Jean Boussier
e974c58bf9 Set the execution context from AC::Metal rather than AbstractController
The later is used by totally different codepaths such as mailers.

Fix: https://github.com/rails/rails/pull/43598
2021-11-15 15:36:28 +01:00