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

Allow call assert_enqueued_with and assert_enqueued_email_with with no block #33258

Conversation

bogdanvlviv
Copy link
Contributor

Example of assert_enqueued_with with no block

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:

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

…th 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 rails#33243
@rails-bot
Copy link

r? @sgrif

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

@rafaelfranca rafaelfranca merged commit 1f42026 into rails:master Jun 29, 2018
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Jun 29, 2018
It isn't allowed to execute `assert_enqueued_email_with` without block
See rails#33243

We might allow to do it in Rails 6.0. See rails#33258.
@bogdanvlviv bogdanvlviv deleted the allow-callassert_enqueued_with-with-no-block branch June 29, 2018 12:54
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Jun 29, 2018
Rename `in_block_job` to `enqueued_job` since this variable can refer not only
to jobs that were created in the block.
See rails#33258.

Return back accidentally removed test to activejob/test/cases/test_helper_test.rb
See rails#33258.

Fix name of tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants