Commit Graph

49 Commits

Author SHA1 Message Date
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
Rafael Mendonça França
ddc7fb6e6e
Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob 2021-11-17 21:51:11 +00:00
Ryuta Kamizono
e1c62dcee4 Fix "warning: instance variable @previous_delivery_method not initialized" 2021-04-13 22:21:44 +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
eileencodes
336a07b9a4
Revert "Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob"
This reverts commit 0f9249c93f402d276730fcfaba1ed1b876ee7c26.

Reverted because this wasn't warning in custom jobs and therefore
applications may have not seen the deprecation. We'll need to fix the
deprecation to warn for custom jobs so that applications can migrate.
2020-05-12 15:20:07 -04:00
Rafael Mendonça França
0f9249c93f
Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob 2020-05-05 00:31:14 -04:00
bogdanvlviv
37b72ff5de
Fix ActionMailer assertions don't work for parameterized mail with legacy delivery job
We should backport this to `6-0-stable`.

Fixes https://github.com/rails/rails/issues/37605
2019-10-30 22:22:00 +00: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
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
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
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
Jeremy Daer
0931e17ebf
Fix tests on Mail 2.7
Reverts 4d96be1c27bd6faed957b197a461f18543acebf2
References #31026
2017-10-31 21:44:58 -07:00
Mikkel Malmberg
db6847dcb6 Add assert_enqueued_email_with to ActionMailer::TestHelper 2017-09-27 23:22:49 +02:00
Kir Shatrov
82df8c2ca5 Use frozen string literal in actionmailer/ 2017-07-23 18:17:19 +03: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
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
David Heinemeier Hansson
d5651436d6 Make assert_enqueued_emails + assert_no_enqueued_emails consider parameterized delivery jobs
Needed for testing of parameterized mailers
2017-01-30 13:41:08 +01:00
Xavier Noria
b91ff557ef applies new string literal convention in actionmailer/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:03:39 +02:00
yuuji.yaginuma
49a59cc6a5 assert_emails in block form use the given number as expected value 2015-05-09 18:59:59 +09:00
Aditya Kapoor
7b58423251 remove noise from AM tests 2015-02-07 13:38:18 +05:30
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
George Claghorn
3f17fbd68d Add assert_enqueued_emails and assert_no_enqueued_emails 2015-01-08 09:41:22 -05:00
Cristian Bica
f4ee114746 Deprecated .deliver / .deliver! to .deliver_now / .deliver_now! 2014-08-20 17:48:34 +03:00
Dmitry Polushkin
99f8d4feeb add test coverage for the action mailer 2014-07-04 15:55:33 +01:00
Kirill Nikitin
96f290eac0 Update actionmailer with new hash syntax. 2012-10-07 21:54:14 +04:00
José Valim
972efa11fd Deprecate the old mailer API that was not deprecated yet. 2010-08-29 20:42:13 -03:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Neeraj Singh
b462952886 Use better assertion methods for testing
[#4645 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
Mikel Lindsaar
fd9ee49f38 Moved test of QP into mail 2010-04-11 18:04:56 +10:00
Mikel Lindsaar
dbcf01e631 Removing quoting.rb, upgrade to 2.1.3.6, changing all utf-8 references to UTF-8, updating tests where incorrect encoding 2010-04-11 18:04:55 +10:00
José Valim and Mikel Lindsaar
f30d73bab4 Add new class delivery method API. 2010-01-24 17:31:18 +01:00
Mikel Lindsaar
0750304c01 Migrated over to Mail doing delivery. 2010-01-16 14:02:55 +01:00
Mikel Lindsaar
bf6d0e2bc2 Updating to Mail 1.5.0, including default values for all Message#field_name methods, can access field objects by calling Message#[:field_name] 2010-01-02 22:39:00 -08:00
José Valim
4747a9a57e Getting rid of some warnings in AM suite. 2009-12-27 12:18:46 +01:00
Mikel Lindsaar
747d56881a 131 tests, 309 assertions, 0 failures, 0 errors 2009-11-22 23:20:57 +11:00
Mikel Lindsaar
15d7cac282 Starting again on actionmailer integration with mail 2009-11-12 16:08:50 +11:00
José Valim
e9667ad1f0 Make tests run without deprecation warning (just one left). 2009-11-01 02:23:48 +01:00
Matthew Rudy Jacobs
f4f76772fb abstract all of the ActionMailer delivery methods into their own classes. thereby the following are equivalent
ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.delivery_method = ActionMailer::DeliveryMethod::Smtp

we could equally set our own custom object
as long as it provides the instance method :perform_delivery(mail)

eg.

  class MySmsDeliveryMethod
    def perform_delivery(mail)
      Sms.send(mail['to'], mail['body'])
    end
  end

  MySmsMailer.delivery_method = MySmsDeliveryMethod.new

Signed-off-by: José Valim <jose.valim@gmail.com>
2009-11-01 02:23:47 +01:00
Jeremy Kemper
1c36172c13 Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.
[#1617 state:resolved]
2009-03-08 13:11:58 -07:00
Alexey Mahotkin
84583657f4 Fixed RFC-2045 quoted-printable bug [#1421 state:committed]
http://www.faqs.org/rfcs/rfc2045.html says:

          may be
          represented by an "=" followed by a two digit
          hexadecimal representation of the octet's value.  The
          digits of the hexadecimal alphabet, for this purpose,
          are "0123456789ABCDEF".  Uppercase letters must be
          used; lowercase letters are not allowed.

ActionMailer, however, used "=%02x" specification.

Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
2008-11-20 23:10:15 +01:00
Jeremy Kemper
17ac2a2482 Ruby 1.9 compat: check for minitest's assertion also 2008-11-08 22:49:28 -05:00
Jeremy Kemper
139b92495f * Continue evolution toward ActiveSupport::TestCase and friends. #10679 [Josh Peek]
* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse.  [Jeremy Kemper]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8570 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-05 13:34:15 +00:00
Jeremy Kemper
1ad87adc9f require abstract_unit directly since test is in load path
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8565 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-05 13:32:22 +00:00
David Heinemeier Hansson
6a6367d7d2 Fixed that you don't have to call super in ActionMailer::TestCase#setup (closes #10406) [jamesgolick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8536 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-03 00:40:28 +00:00
Michael Koziarski
2cc0cac3ef Introduce TestCase subclasses for testing rails applications allowing tests to be DRY'd up a bit and to provide a path toward tidying up our monkeypatching of test/unit.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-26 02:21:21 +00:00
Jeremy Kemper
e963354124 Increase mail delivery test coverage. Closes #8692.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7070 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-06-20 06:50:43 +00:00
Jeremy Kemper
ba553f9424 Add assert_emails and assert_no_emails to test the number of emails delivered. Closes #6479.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5436 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-11-05 21:56:18 +00:00