Commit Graph

1698 Commits

Author SHA1 Message Date
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
Christian Schmidt 9a2cbb1ca9 Document delivery_job and deliver_later_queue_name 2021-10-28 17:17:53 +02:00
Daniel Colson ccb3cb573b
Replace ableist language
The word "Crazy" has long been associated with mental illness. While
there may be other dictionary definitions, it's difficult for some of us
to separate the word from the stigmatization, gaslighting, and bullying
that often comes along with it.

This commit replaces instances of the word with various alternatives. I
find most of these more focused and descriptive than what we had before.
2021-10-05 22:27:09 -04:00
Rafael França 02537722f3
Merge pull request #42970 from thutterer/email_address_with_blank_name
Return just the address if name is blank
2021-09-21 18:41:19 -04:00
Yasuo Honda d3bd9cdc1f Address LegacyDeliveryJobTest#test_should_send_mail_correctly failure
This commit addresses LegacyDeliveryJobTest#test_should_send_mail_correctly failure with Ruby 3.1.0 master branch
since https://buildkite.com/rails/rails/builds/79922#1152cdb4-a52a-4144-b4f1-5399ecd00a3e

* Steps to reproduce

```ruby
$ ruby -v
ruby 3.1.0dev (2021-09-20T11:16:45Z master b61064b821) [x86_64-linux]
$ cd actionmailer
$ bin/test test/legacy_delivery_job_test.rb -n test_should_send_mail_correctly
Run options: -n test_should_send_mail_correctly --seed 34109

F

Failure:
LegacyDeliveryJobTest#test_should_send_mail_correctly [/home/yahonda/src/github.com/rails/rails/actionmailer/test/legacy_delivery_job_test.rb:78]:
No performed job found with {:job=>LegacyDeliveryJobTest::LegacyDeliveryJob, :args=>["DelayedMailer", "test_message", "deliver_now", 1, 2, 3]}

Potential matches: {"job_class"=>"LegacyDeliveryJobTest::LegacyDeliveryJob", "job_id"=>"37a3bde7-6580-4ae1-9213-8fa69a108fd8", "provider_job_id"=>nil, "queue_name"=>"test_queue", "priority"=>nil, "arguments"=>["DelayedMailer", "test_message", "deliver_now", {"args"=>[1, 2, 3], "_aj_ruby2_keywords"=>["args"]}], "executions"=>0, "exception_executions"=>{}, "locale"=>"en", "timezone"=>nil, "enqueued_at"=>"2021-09-20T13:56:30Z", :job=>LegacyDeliveryJobTest::LegacyDeliveryJob, :args=>["DelayedMailer", "test_message", "deliver_now", {:args=>[1, 2, 3]}], :queue=>"test_queue", :priority=>nil}

bin/test test/legacy_delivery_job_test.rb:66

Finished in 0.182945s, 5.4661 runs/s, 5.4661 assertions/s.
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
$
```

This behavior change has been introduced via https://github.com/ruby/ruby/pull/4705 .
Here are how `perform` method parameters are handled with Ruby 3.0.2 and
Ruby 3.1.0-dev

* Ruby 3.1.0 dev

```ruby
% ruby -v
ruby 3.1.0dev (2021-09-18T16:05:40Z master f9fd04ffbc) [x86_64-darwin21]
% irb
irb(main):001:1* def perform(mailer, mail_method, delivery_method, *args)
irb(main):002:0> end
=> :perform
irb(main):003:0> method(:perform).parameters
=> [[:req, :mailer], [:req, :mail_method], [:req, :delivery_method], [:rest, :args]]
irb(main):004:0> ruby2_keywords(:perform)
=> nil
irb(main):005:0> method(:perform).parameters
=> [[:req, :mailer], [:req, :mail_method], [:req, :delivery_method], [:rest, :args], [:keyrest, :**]]
irb(main):006:0>
```

* Ruby 3.0.2

```
% ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin21]
% irb
irb(main):001:1* def perform(mailer, mail_method, delivery_method, *args)
irb(main):002:0> end
=> :perform
irb(main):003:0> method(:perform).parameters
=> [[:req, :mailer], [:req, :mail_method], [:req, :delivery_method], [:rest, :args]]
irb(main):004:0> ruby2_keywords(:perform)
=> nil
irb(main):005:0> method(:perform).parameters
=> [[:req, :mailer], [:req, :mail_method], [:req, :delivery_method], [:rest, :args]]
irb(main):006:0>
```
2021-09-20 23:55:35 +09:00
Thomas Hutterer 524c4cad07 Return just the address if name is blank
Otherwise the returned string would look like " <foo@example.com>".
2021-09-16 09:24:27 +02:00
Rafael Mendonça França d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França 9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
Rafael Mendonça França 18707ab17f
Standardize nodoc comments 2021-07-29 21:18:07 +00:00
Alexandre Ruban bcd1333e3f Default values are not evaluated when overridden 2021-06-08 10:06:14 +02:00
Rafael Mendonça França 52db7f2ef3
Configure a default timeout for the smtp delivery method
The default is set to 5 and only applied for new applications or
applications that opt-in for this new default.

Closes #42089.

[André Luis Leal Cardoso Junior + Rafael Mendonça França]
2021-04-28 03:59:19 +00:00
Rafael França 503e83dc5e
Merge pull request #41248 from andrehjr/add-action-mailer-default-timeout
Document open_timeout and read_timeout for SMTP Settings on ActionMailer
2021-04-27 23:12:56 -04:00
Ryuta Kamizono e1c62dcee4 Fix "warning: instance variable @previous_delivery_method not initialized" 2021-04-13 22:21:44 +09:00
Rafael Mendonça França 4354e3ae49
Don't define methods using the method modifier in the same line as the method
Our style guide use block method modifiers, not inline method modifiers.
2021-04-12 18:49:54 +00:00
Jean Boussier 3f59640016 Stop checking if ruby2_keywords is defined 2021-04-11 13:42:02 +02:00
Geremia Taglialatela 3da5267f1a Fix ActionMailer's deliver later default queue
The default queue name used by `deliver_later` is no longer `mailers`.

This commit removes the misleading information from the class
documentation

Ref: #40848
2021-03-05 10:16:55 +01:00
Rafael Mendonça França 1b455e2e9d
Rails 6.2 is now Rails 7.0
We have big plans for the next version of Rails and that
require big versions.
2021-02-04 16:47:16 +00:00
Rafael Mendonça França 6487836af8
Rails 7 requires Ruby 2.7 and prefer Ruby 3+
The code cleanup is comming in later commits but this
already remove support to Ruby < 2.7.
2021-02-04 16:34:53 +00:00
André Luis Leal Cardoso Junior 161c43271d Document open_timeout and read_timeout for SMTP Settings on ActionMailer 2021-02-03 22:10:58 -03:00
Rafael Mendonça França 077c66d5d6
Rename master to main in all code references 2021-01-19 20:46:33 +00:00
Ryuta Kamizono 2b0b5a75c0 Bump license years to 2021 [ci skip] 2021-01-01 12:21:20 +09:00
Paul Keen 7d7bd2bfba Make sure that mailers will use default job queue
Use "default" as default queue for mailers test helpers
2020-12-18 23:35:59 +02:00
Rafael Mendonça França 59f7f5889e
Start Rails 6.2 development 🎉 2020-12-03 01:35:29 +00:00
Rafael Mendonça França 8389f9902c
Preparing for 6.1.0.rc1 release 2020-11-02 21:12:47 +00:00
Ryuta Kamizono 8512213a39 Fix deprecation will be removed version s/Rails 6.1/Rails 6.2/ 2020-10-30 10:11:29 +09:00
Akira Matsuda 2013ebbd4a class_attributes are defined as public methods 2020-10-27 12:13:32 +09:00