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

@rails-bot rails-bot commented Oct 28, 2018

r? @schneems

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

actionmailer/lib/action_mailer/test_helper.rb Outdated Show resolved Hide resolved
actionmailer/lib/action_mailer/test_helper.rb Outdated Show resolved Hide resolved
@Edouard-chin Edouard-chin force-pushed the ec-mail-test-helper branch from f2410bb to 375841d Nov 21, 2018
@rails-bot rails-bot bot added the activejob label Nov 21, 2018
- 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 Edouard-chin force-pushed the ec-mail-test-helper branch from 375841d to d813837 Nov 21, 2018
@Edouard-chin
Copy link
Member Author

@Edouard-chin Edouard-chin commented Nov 21, 2018

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.
@Edouard-chin Edouard-chin force-pushed the ec-mail-test-helper branch from d813837 to e139a3c Nov 21, 2018
@rafaelfranca rafaelfranca merged commit 47ab6b3 into rails:master Nov 21, 2018
2 checks passed
@Edouard-chin Edouard-chin deleted the ec-mail-test-helper branch Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants