Commit Graph

1760 Commits

Author SHA1 Message Date
Rafael Mendonça França
992a126c6e
Remove deprecated params via :args for assert_enqueued_email_with 2023-11-22 22:11:32 +00:00
Rafael Mendonça França
2bd6cf5177
Remove deprecated config.action_mailer.preview_path 2023-11-22 22:11:31 +00:00
Xavier Noria
37833debc6 Remove obsolete workaround in Action Mailer
The buggy interaction between config.paths and config.autoload_paths
described in the comment was fixed in 7.1.2.
2023-11-21 21:30:30 +01:00
Thiago Pradi
3673aea825 removing old and not used actionmailer fixtures 2023-11-19 23:25:40 -03:00
Jonathan Hefner
99ddec8d2d Use h2 headings for ActionMailer::Base [ci-skip]
For SEO purposes, there should only be one `<h1>` per page.
2023-10-26 17:37:32 -05:00
Jean Boussier
02e679ba75 Get rid of the jruby_skip test helper
The last test calling it actually passes on latest
JRuby.
2023-10-02 13:01:44 +02:00
Bart de Water
95b6fbd00f Stop building AS::Notifications::Event manually
It's possible since Rails 6 (3ea2857943dc294d7809930b4cc5b318b9c39577) to let the framework create Event objects, but the guides and docs weren't updated to lead with this example.

Manually instantiating an Event doesn't record CPU time and allocations, I've seen it more than once that people copy-pasting the example code get confused about these stats returning 0. The tests here show that - just like the apps I've worked on - the old pattern keeps getting copy-pasted.
2023-09-29 12:34:23 -04:00
Rafael Mendonça França
fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Rafael Mendonça França
e5386cb402
Preparing for 7.1.0.rc1 release 2023-09-27 03:08:31 +00:00
Rafael Mendonça França
e7009b14b6
Remove unused mailer 2023-09-27 02:45:56 +00:00
Christoph Geschwind
647e39b278
Log delivery errors in ActionMailer::LogSubscriber
In case of mail delivery errors, the old ActionMailer::LogSubscriber
erroneously logged a "Delivered mail ..." line.
With this change it checks the passed exception object and logs a
"Failed delivery of mail" line instead.

Co-authored-by: Christian Esser <c_esser@yahoo.de>
2023-09-27 02:45:55 +00:00
Alex Ghiculescu
9a2cf33f21
Introduce ActionMailer::FormBuilder
Fixes https://github.com/rails/rails/issues/48477

Using forms inside emails is not common, but it's possible, and it's also possible to share views between controllers and mailers. Currently if a controller sets a `default_form_builder` that's different from the global config, mailers that use the same views will not default to the same `FormBuilder`. To fix this, this PR adds a `default_form_builder` method for mailers that does the same thing as its controller sibling.
2023-09-25 20:33:22 +00:00
Shouichi Kamiya
51ac8b9f6f Enable Minitest/LiteralAsActualArgument
There are assertions that expected/actual arguments are passed in the
reversed order by mistake. Enabling the LiteralAsActualArgument rule
prevents this mistake from happening.

The existing tests were auto-corrected by rubocop with a bit of
indentation adjustment.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-09-13 10:09:32 +09:00
Rafael Mendonça França
699dfdb426
Preparing for 7.1.0.beta1 release 2023-09-13 00:36:01 +00:00
Petrik
6998747947 Remove internal usage of require_dependency
Since 6983a89c726243fb38fe28cff49cba3a5f63ba6f `require_dependency` is
obsolete  since Rails stopped supporting classic mode.
It is only used by engines that need to support classic mode as well.

We can safely remove internal usage of `require_dependency`.

It was only used in the ActionMailer::Preview which is using just
`require` anyway.
2023-09-05 16:05:48 +02:00
Xavier Noria
b16adcd4e4 Generate config.autoload_lib(...) for new apps 2023-08-25 09:22:25 +02:00
Martin Spickermann
dd8b0e4684 Sort mailers on mailer preview page alphabetically 2023-08-21 11:11:25 +02:00
Mike Dalessio
8a57ba8c0e
Update Action View and Dispatch to use Rails::Dom::Testing helpers
Use the helpers introduced in rails-dom-testing 2.2.0 instead of
managing the HTML parsers as was done in #48523.

See also related #47144 / ad79ed0e
2023-08-03 11:17:38 -04:00
Alex Ghiculescu
455e922b49
Introduce capture_emails and capture_broadcasts (#48798) 2023-07-25 06:42:54 +02:00
Alex Ghiculescu
ba70a5be86 Make perform_enqueued_jobs compatible with all Active Job adapters 2023-06-28 20:08:08 +10:00
zzak
dd89f600f7
🔗 Remove RDoc auto-link from Rails module everywhere 2023-06-23 10:49:30 +09:00
zzak
2cdb05f7e1
Make ActionMailer::TestCase#read_fixture public
Since this method has been documented in the guides for ages, it's probably safe.

https://guides.rubyonrails.org/testing.html#revenge-of-the-fixtures

TODO: I don't like how these methods are documented on
ActionMailer::TestCase::Behavior, even though the API is meant to be
exposed through ActionMailer::TestCase
2023-06-20 15:44:52 +09:00
zzak
722d4f6582
Unlink Rails constant from READMEs 2023-05-29 15:14:44 +09:00
zzak
38bef29064
Replace all occurrences of '<tt>(\w+::\w+::\w+)</tt>' with '+$1+'
E.g.:

* <tt>Rails::Command::NotesCommand</tt> -> +Rails::Command::NotesCommand+

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2023-05-25 06:56:17 +09:00
zzak
e3c73fd183
Replace all occurrences of '<tt>(\w+::\w+)</tt>' with '+$1+'
E.g.:

* <tt>ActiveRecord::Base</tt> -> +ActiveRecord::Base+

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2023-05-25 06:52:32 +09:00
Shivam Chahar
f30fc95c75 Remove redundant test 2023-05-22 19:31:46 +05:30
Jonathan Hefner
fc9470aa97
Merge pull request #48194 from jonathanhefner/assert_enqueued_email_with-deprecate-params-via-args
Deprecate params via `:args` for `assert_enqueued_email_with`
2023-05-19 17:26:50 -05:00
Hartley McGuire
d028c14b03
Link rescue_from from modules including Rescuable
Also add some additional words to make it clear that the modules also
implement handling the exceptions configured with rescue_from, because
it was not immediately clear that happened without reading the code.
2023-05-18 12:54:16 -04:00
Jonathan Hefner
19df946585 Deprecate params via :args for assert_enqueued_email_with
In #45752, a `:params` kwarg was added to `assert_enqueued_email_with`
so that mailer params and args could be specified simultaneously.
However, for backward compatibility, the old behavior of treating an
`:args` Hash as params was preserved.  The result is that if both
`:params` and `:args` are specified and `:args` is a Hash, `:params` is
ignored.

This commit deprecates specifying params via `:args` (i.e. passing a
Hash to `:args`).

After the deprecated behavior is removed, it will be possible to pass
a Hash to `:args`, and the Hash will be treated as named args instead.
2023-05-11 14:11:17 -05:00
Max Chernyak
96f19e965b Add matcher support to assert_enqueued_email_with
Support args/params proc matchers in `assert_enqueued_email_with` to
make it behave more like `assert_enqueued_with`.

Fix #46621.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-05-11 11:43:54 -05:00
Jean Boussier
06d2c2d15b Refactor ActionView::Template::Types to avoid delegation
The `Type` class was introduced in https://github.com/rails/rails/pull/23085
for the sole purpose of breaking the dependency of Action View on Action Dispatch.

Unless you are somehow running Action View standalone, this is actually
never used.

So instead of delegating, we can use constant swapping, this saves us
a useless layer.

Ultimately we could consider moving `Mime::Types` into Active Support
but it requires some more thoughts.
2023-05-08 10:34:46 +09:00
Shivam Chahar
88f9bc1237 Remove noise from actionmailer callbacks test 2023-04-26 21:38:54 +05:30
John Hawthorn
6cd8dddb92
Merge pull request #47630 from bensheldon/action_mailer_around_delivery
Add `*_deliver` callbacks for Action Mailer
2023-04-04 14:58:15 -07:00
Petrik
c09f5fa956 Add missing headers to Action Mailbox/Mailer/Text/View docs [ci-skip]
Having a h1 heading will improve SEO and makes things look more consistent.
2023-04-02 17:47:17 +02:00
Rafael Mendonça França
055572ec36
Correct documentation of assert_emails 2023-03-31 21:24:10 +00:00
Ben Sheldon
468d806406 Add *_deliver callbacks for Action Mailer 2023-03-29 17:12:19 -07:00
Petrik
7c94708d24 Include READMEs in main framework pages of the API documentation
Currently when opening the main framework pages there is no introduction
to the framework. Instead we only see a whole lot of modules and the
`gem_version` and `version` methods.

By including the READMEs using the `:include:` directive each frameworks
has a nice introduction.
For markdown READMEs we need to add the :markup: directive.

[ci-skip]

Co-authored-by: zzak <zzakscott@gmail.com>
2023-03-21 21:16:28 +01:00
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