Commit Graph

585 Commits

Author SHA1 Message Date
Fumiaki MATSUSHIMA
61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
John Hawthorn
4e6c8045c3 Add test and change how format set in ActionMailer
Previously this used self.formats= to set the format which render would
use to find templates. This worked, but was untested, and looked a
little confusing because it was doing the mutation within a loop.

This commit replaces the assignment with passing formats: [format] into
the render call, which makes it more obvious that that's the purpose of
the format. It also adds a test to verify the formats being used.
2019-03-01 14:07:59 -08:00
Aaron Patterson
ff6b713f5e
Merge pull request #35293 from rails/remove-rendered-format-from-cache
Pass the template format to the digestor
2019-02-19 13:45:30 -08:00
Yoshiyuki Hirano
ed3f315907 Auto correct rubocop offenses
Offenses:

railties/lib/rails/autoloaders.rb:1:1: C: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
module Rails
^
actionmailer/test/base_test.rb:917:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
actionmailer/test/base_test.rb:917:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
actionmailer/test/base_test.rb:917:5: C: [Corrected] Style/RedundantBegin: Redundant begin block detected.
    begin
    ^^^^^
actionmailer/test/base_test.rb:918:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
      events = []
  ^^^^
actionmailer/test/base_test.rb:930:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end.
actionmailer/test/base_test.rb:930:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
2019-02-17 17:12:22 +09:00
Aaron Patterson
a3a98606f3
pass format to the digestor 2019-02-16 10:57:51 -08:00
Jaap van der Plas
2488901da8 Don’t log recipients when sending mail
Since production applications typically run with log level info and
email adresses should be considered as sensitive data we want to prevent 
them from ending up in the logs. In development mode (with log level
debug) they are still logged as part of the Mail::Message object.
2019-02-13 09:55:38 -05:00
Gannon McGibbon
5d6578d15b Fix legacy fallback for parameterized mailers 2019-01-07 17:38:28 -05:00
bogdanvlviv
2e29488a89
Remove mention about receive.action_mailer from the AS instrumentation guide
Since e3f832a7433a291a51c5df397dc3dd654c1858cb `ActionMailer::Base.receive` is
deprecated.
2018-12-28 11:23:27 +02:00
George Claghorn
e3f832a743 Deprecate ActionMailer::Base.receive in favor of Action Mailbox 2018-12-27 21:17:58 -05:00
Ryuta Kamizono
892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00
pavel
bf01cc6744 fix tests for mail 2.8 2018-12-19 18:12:58 -08:00
Gannon McGibbon
f5050d998d Add MailDeliveryJob for unified mail delivery
Add `MailDeliveryJob` for delivering both regular and parameterized mail.
Deprecate using `DeliveryJob` and `Parameterized::DeliveryJob`.
2018-12-04 11:00:34 -05:00
Gannon McGibbon
ebf484a640 Add yield to with_delivery_job test helper
Adds yield to parameterized mail test helper so assertions
passed into with_delivery_job are actually ran.
2018-11-30 17:38:26 -05:00
Gannon McGibbon
60339da5bc Deliver parameterized mail with DeliveryJob
Deliver parameterized mail with `ActionMailer::DeliveryJob`
and remove `ActionMailer::Parameterized::DeliveryJob`.
2018-11-22 18:37:53 -05:00
Edouard CHIN
e139a3ce13 Fix ActionMailer assertion not working for mail defining delivery_job:
- If a Mail defines a custom delivery_job, all ActionMailer assertion
  helper (assert_emails, assert_enqueued_emails ...) wouldn't work.

  ```ruby
    MyMailer < ApplicationMailer
      self.delivery_job = MyJob
    end

    # This assertion will fail
    assert_emails(1) do
      MyMailer.my_mail.deliver_later
    end

  This PR leverage the new ActiveJob feature that accepts Procs for the
  `only` keyword and check if the delivery job is one of ActionMailer
   registered ones.
2018-11-21 23:17:04 +01:00
Rafael Mendonça França
72062c8c9d Merge pull request #22534 from evopark/master
ActionMailer: support overriding template name in multipart
2018-11-19 19:23:44 -05:00
yuuji.yaginuma
d2d6f6b7db Fix tests on Mail 2.7.1
Up to `2.7.0`, encoding was chosen using `Mail::Encodings::TransferEncoding.negotiate`,
and base64 encoding was used.
In `2.7.1`, when `transfer_encoding` is not specified, the encoding
of the message is respected.
Related to: dead487e02

However, what chosen for transfer encoding is not essential in these tests.
To test more accurately, confirm that the decoded body instead.
2018-10-14 14:44:47 +09:00
Luke Pearce
c90c6c1344 Parameterized mailers can configure delivery job
Setting parameterized_delivery_job on a mailer class will cause Parameterized::MessageDelivery to use
the specified job instead of ActionMailer::Parameterized::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.parameterized_delivery_job = MyCustomDeliveryJob
      ...
    end
2018-10-05 17:02:40 +01:00
Rafael Mendonça França
f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
Aaron Patterson
d34bd0d2d5
Merge pull request #33974 from rails/remove-catch-all-from-am
This patch removes deprecated catch-all routes from AM
2018-09-25 09:27:56 -07:00
Aaron Patterson
fefcb36811
This patch removes deprecated catch-all routes from AM
It also removes a monkey patch from AM::Base
2018-09-24 16:12:44 -07:00
Kasper Timm Hansen
22dc2b3db8
Merge pull request #33949 from sjain1107/no-private-def
Remove private def
2018-09-23 19:39:15 +02:00
Sakshi Jain
0fe2bb816f Remove private def 2018-09-23 21:27:44 +05:30
yuuji.yaginuma
1b86d90136 Enable Performance/UnfreezeString cop
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.

```ruby
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "benchmark-ips"
end

Benchmark.ips do |x|
  x.report('+@') { +"" }
  x.report('dup') { "".dup }
  x.compare!
end
```

```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
                  +@   282.289k i/100ms
                 dup   187.638k i/100ms
Calculating -------------------------------------
                  +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                 dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s

Comparison:
                  +@:  6775299.3 i/s
                 dup:  3320400.7 i/s - 2.04x  slower

```
2018-09-23 08:56:55 +09:00
Yoshiyuki Kinjo
576209b45b Add perform_deliveries to a payload of deliver.action_mailer notification. 2018-09-09 20:17:36 +09:00
Yoshiyuki Kinjo
383b8bc8e2 Skip delivery notification when perform_deliveries is false. 2018-09-08 17:29:28 +09:00
Kazuhiro Sera
52919f3d13 Fix the obvious typos detected by github.com/client9/misspell 2018-08-08 21:55:46 +09:00
bogdanvlviv
4382fcbc22
Allow call assert_enqueued_with and assert_enqueued_email_with with no block
Example of `assert_enqueued_with` with no block
```ruby
def test_assert_enqueued_with
  MyJob.perform_later(1,2,3)
  assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low')

  MyJob.set(wait_until: Date.tomorrow.noon).perform_later
  assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
end
```

Example of `assert_enqueued_email_with` with no block:
```ruby
def test_email
  ContactMailer.welcome.deliver_later
  assert_enqueued_email_with ContactMailer, :welcome
end

def test_email_with_arguments
  ContactMailer.welcome("Hello", "Goodbye").deliver_later
  assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
end
```

Related to #33243
2018-06-29 15:37:02 +03:00
Kota Miyake
b74edd37c5 ActionMailer::Base can unregister observer(s) and interceptor(s). (#32207)
* ActionMailer::Base can unregister observer(s) and interceptor(s).

One or multiple mail observers can be unregistered using
`ActionMailer::Base.unregister_observers` or
`ActionMailer::Base.unregister_observer`.

One or multiple mail interceptors can be unregistered using
`ActionMailer::Base.unregister_interceptors` or
`ActionMailer::Base.unregister_interceptor`.

For preview interceptors, it's possible to use
`ActionMailer::Base.unregister_preview_interceptors` or
`ActionMailer::Base.unregister_preview_interceptor`.

* Ensure to be reset registered observer(s) and interceptor(s)

* Add explanation to CHANGELOG

* Add original author's name

[Kota Miyake + Rafael Mendonça França + Claudio Ortolina]
2018-05-30 17:36:24 -04:00
Daniel Colson
a1ac18671a Replace assert ! with assert_not
This autocorrects the violations after adding a custom cop in
3305c78dcd.
2018-04-19 08:11:33 -04:00
Gannon McGibbon
96218b4568 Perform email jobs in #assert_emails
Perform enqueued delivery jobs in #assert_emails and #assert_no_emails.
2018-03-12 15:35:18 -04:00
Daniel Colson
82c39e1a0b Use assert_empty and assert_not_empty 2018-01-25 23:32:59 -05:00
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
Daniel Colson
0d50cae996 Use respond_to test helpers 2018-01-25 23:32:58 -05:00
Ryuta Kamizono
6003dafc1f Merge pull request #30391 from jbourassa/fix-actionmailer-lambda-default
Fix actionmailer lambda default
2018-01-24 06:01:25 +09:00
Ryuta Kamizono
2b35826389 Enable Layout/SpaceBeforeComma rubocop rule, and fixed more
Follow up of #31390.
2017-12-12 20:00:50 +09:00
Jeremy Daer
0931e17ebf
Fix tests on Mail 2.7
Reverts 4d96be1c27bd6faed957b197a461f18543acebf2
References #31026
2017-10-31 21:44:58 -07:00
Rafael França
a8ebd48559
Merge pull request #31004 from shuheiktgw/remove_unnecessary_returns
Remove redundant return statements
2017-10-31 01:47:35 -04:00
Shuhei Kitagawa
03dd47ff21 removed unnecessary semicolons 2017-10-28 17:39:58 +09:00
Shuhei Kitagawa
c40b4428e6 removed unnecessary returns 2017-10-28 17:20:38 +09:00
Mikkel Malmberg
db6847dcb6 Add assert_enqueued_email_with to ActionMailer::TestHelper 2017-09-27 23:22:49 +02:00
Jimmy Bourassa
fbb2fc8aa7 Fix AM::Base.default proc arity breaking change
PR #29270 changed the number of arguments that gets passed to Procs
defined in ActionMail::Base.default. With this changeset, Procs can
now have 1 or 0 arguments

Also adds test coverage for AM::Base.default Proc arity.
2017-08-29 09:42:28 -04:00
Cameron Cundiff
9a74c7b99b Do not generate default alt text in image tags
- Auto-generating content from the filename of an image is not suitable
  alternative text; alt text that isn't fully considered can be
  distracting and fatiguing for screen readers users (blind, low vision,
  dyslexic people).
- Setting a filename fallback short circuits screen reader default
  behavior and configuration for blank descriptions.
- Setting poor defaults also creates false negatives for accessibility
  linting and testing software, that makes it harder to improve
  application accessibility.

***

- After this change, if authors leave images without alt text, screen
  readers will fallback to default behavior for missing alt text.
- Also with this change, Automated linting and testing tools will
  correctly generate warnings.

[Fixes #30096]
2017-08-17 16:13:15 -04:00
yuuji.yaginuma
2f469dc308 Clear mail after test
If clear it before the test, the mail of the last executed test will not
be correctly cleared.

Therefore, executing the test with seed below will result in an error.

```
./bin/test -w --seed 55480
Run options: --seed 55480

# Running:

...........................................................................................................................................................F

Failure:
MailDeliveryTest#test_does_not_increment_the_deliveries_collection_on_error [/home/yaginuma/program/rails/master_y_yagi/rails/actionmailer/test/delivery_methods_test.rb:221]:
--- expected
+++ actual
@@ -1 +1 @@
-[]
+[#<Mail::Message:47011389364640, Multipart: false, Headers: <Date: Mon, 14 Aug 2017 07:48:40 +0900>, <From: test-sender@test.com>, <To: test-receiver@test.com>, <Message-ID: <5990d748ea5b2_29342ac1af8bcf40886f7@yaginuma.mail>>, <Subject: Test Subject>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>]

bin/test test/delivery_methods_test.rb:216
```
2017-08-14 07:49:13 +09:00
Rafael Mendonça França
feb1ddae02 Merge remote-tracking branch 'origin/master' into unlock-minitest 2017-08-01 17:34:14 -04:00
Kir Shatrov
82df8c2ca5 Use frozen string literal in actionmailer/ 2017-07-23 18:17:19 +03:00
Kasper Timm Hansen
aad42dce10 Merge branch 'master' into unlock-minitest 2017-07-15 21:17:27 +02:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Matthew Draper
3420a14590 Merge pull request #29540 from kirs/rubocop-frozen-string
Enforce frozen string in Rubocop
2017-07-02 01:11:50 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00