Skip to content

Allow call assert_enqueued_with and assert_enqueued_email_with with no block - #33258

Merged
rafaelfranca merged 1 commit into
rails:masterfrom
bogdanvlviv:allow-callassert_enqueued_with-with-no-block
Jun 29, 2018
Merged

Allow call assert_enqueued_with and assert_enqueued_email_with with no block#33258
rafaelfranca merged 1 commit into
rails:masterfrom
bogdanvlviv:allow-callassert_enqueued_with-with-no-block

Conversation

@bogdanvlviv

Copy link
Copy Markdown
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
Copy Markdown

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.

4 participants