Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActionMailer assertion not working for mail defining delivery_job: #34339

Merged
merged 2 commits into from
Nov 21, 2018

Conversation

Edouard-chin
Copy link
Member

@Edouard-chin Edouard-chin commented Oct 28, 2018

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.
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.

@rails-bot
Copy link

r? @schneems

(@rails-bot has picked a reviewer for you, use r? to override)

- That feature is useful to enqueue or assert that jobs got enqueued
  or performed based on dynamic conditions.
  We will be able to leverage that feature to fix all ActionMailer
  assertion helper issue when a Mailer define a custom delivery job
  (see next commit).
@Edouard-chin
Copy link
Member Author

Sorry for the delay, this is ready with a new implementation

- 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.
@rafaelfranca rafaelfranca merged commit 47ab6b3 into rails:master Nov 21, 2018
@Edouard-chin Edouard-chin deleted the ec-mail-test-helper branch November 21, 2018 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants