Flowdock
method

deliver_enqueued_emails

Importance_2
v7.1.3.2 - Show latest stable - 0 notes - Class: ActionMailer::TestHelper
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8
  • 3.0.0
  • 3.0.9
  • 3.1.0
  • 3.2.1
  • 3.2.8
  • 3.2.13
  • 4.0.2
  • 4.1.8
  • 4.2.1
  • 4.2.7
  • 4.2.9
  • 5.0.0.1
  • 5.1.7
  • 5.2.3
  • 6.0.0
  • 6.1.3.1
  • 6.1.7.7
  • 7.0.0
  • 7.1.3.2 (0)
  • What's this?
deliver_enqueued_emails(queue: nil, at: nil, &block) public

Delivers all enqueued emails. If a block is given, delivers all of the emails that were enqueued throughout the duration of the block. If a block is not given, delivers all the enqueued emails up to this point in the test.

def test_deliver_enqueued_emails
  deliver_enqueued_emails do
    ContactMailer.welcome.deliver_later
  end

  assert_emails 1
end

def test_deliver_enqueued_emails_without_block
  ContactMailer.welcome.deliver_later

  deliver_enqueued_emails

  assert_emails 1
end

If the :queue option is specified, then only the emails(s) enqueued to a specific queue will be performed.

def test_deliver_enqueued_emails_with_queue
  deliver_enqueued_emails queue: :external_mailers do
    CustomerMailer.deliver_later_queue_name = :external_mailers
    CustomerMailer.welcome.deliver_later # will be performed
    EmployeeMailer.deliver_later_queue_name = :internal_mailers
    EmployeeMailer.welcome.deliver_later # will not be performed
  end

  assert_emails 1
end

If the :at option is specified, then only delivers emails enqueued to deliver immediately or before the given time.

Show source
Register or log in to add new notes.