Commit Graph

527 Commits

Author SHA1 Message Date
Sharang Dashputre
9203d2b3e1
Update test_helper_test.rb
Fix typo `wiht` -> `with`
2018-09-12 15:35:22 +05:30
Rafael França
66ab9c74dd
Merge pull request #33823 from stoodfarback/aj_backburner_fix_priority
ActiveJob Backburner adapter: fix priority
2018-09-10 17:50:37 -04:00
Eileen M. Uchitelle
12b32d8049
Merge pull request #33826 from tgturner/activejob-retry-attempts
retry_on argument `attempts` clarification
2018-09-09 15:22:18 -04:00
Graham Turner
86aa8f8c56 clarifies documentation around the attempts arugment to retry_on 2018-09-09 09:46:20 -04:00
yuuji.yaginuma
9d848d8545 Add missing perform_enqueued_jobs to error logging test
Without `perform_enqueued_jobs`, job are not executed and assertion is not done.
2018-09-09 13:46:43 +09:00
stoodfarback
fc4e7d44c8 ActiveJob Backburner adapter: fix priority
The priority wasn't being passed from ActiveJob to Backburner, despite
priority being supported. This also brings it inline with the docs,
which mark Backburner as supporting priorities in the "Backend Features"
table: https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html
2018-09-07 21:55:05 -07:00
Rafael França
5bbaae0d20
Merge pull request #33751 from steves/add_retry_notifications_to_aj
Add hooks to ActiveJob around retries and discards
2018-08-30 13:39:51 -05:00
Steve S
3bf33d7c2c
Move ActiveJob retry and discard logging into log subscriber 2018-08-30 13:07:37 -04:00
Steve S
26dc9bc8ee
Add hooks to ActiveJob around retries and discards 2018-08-29 13:28:55 -04:00
Matthew Draper
068fe7dc90
Merge pull request #33718 from kddeisz/permit-list
Finish converting whitelist and blacklist references
2018-08-29 14:07:37 +09:30
Rafael Mendonça França
a8fff60814
Add test to make sure the custom object key can't be serialized 2018-08-28 16:31:15 -04:00
Kevin Deisz
7c9751d7fe
Permit list usage cleanup and clearer documentation 2018-08-27 09:51:46 -04:00
Kevin Deisz
0efecd913c
Convert remaining usage of whitelist and blacklist 2018-08-24 16:16:41 -04:00
utilum
96ac7e4cde Remove duplicate test
This patch corrects a duplicate method name introduced in #33635.

Also fixes typo in method names.
2018-08-22 01:41:09 -07:00
bogdanvlviv
b8576425ee
DRY in assert_enqueued_jobs 2018-08-20 13:05:29 +03:00
bogdanvlviv
b7beb5d4e5
Fix formatting of ActiveJob::TestHelper api docs 2018-08-20 13:05:29 +03:00
bogdanvlviv
2ec60fb818
Allow assert_performed_with to be called without a block.
Example:
```
def test_assert_performed_with
  MyJob.perform_later(1,2,3)

  perform_enqueued_jobs

  assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high')
end
```

Follow up #33626.
2018-08-20 13:05:29 +03:00
bogdanvlviv
11634e8ef8
Fix assert_performed_jobs and assert_no_performed_jobs
Execution of `assert_performed_jobs`, and `assert_no_performed_jobs`
without a block should respect passed `:except`, `:only`, and `:queue` options.
2018-08-20 13:05:29 +03:00
bogdanvlviv
2bf8b4eb0e
Add changelog entry about adding :queue option to job assertions and helpers
Note that it removes changelog entry of #33265 since the entry in this commits
includes that too.
2018-08-20 13:05:29 +03:00
bogdanvlviv
de4420da44
Allow :queue option to assert_no_performed_jobs.
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will not be performed.

Example:
```
def test_assert_no_performed_jobs_with_queue_option
  assert_no_performed_jobs queue: :some_queue do
    HelloJob.set(queue: :other_queue).perform_later("jeremy")
  end
end
```
2018-08-20 13:05:29 +03:00
bogdanvlviv
d50fb21e4d
Allow :queue option to assert_performed_jobs.
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will be performed.

Example:
```
def test_assert_performed_jobs_with_queue_option
  assert_performed_jobs 1, queue: :some_queue do
    HelloJob.set(queue: :some_queue).perform_later("jeremy")
    HelloJob.set(queue: :other_queue).perform_later("bogdan")
  end
end
```
2018-08-20 13:05:29 +03:00
bogdanvlviv
e0cf042fa2
Fix perform_enqueued_jobs
Set
````
queue_adapter.perform_enqueued_jobs = true
queue_adapter.perform_enqueued_at_jobs = true
queue_adapter.filter = only
queue_adapter.reject = except
queue_adapter.queue = queue
```
if block given.
Execution of `flush_enqueued_jobs` doesn't require that.
2018-08-20 13:05:22 +03:00
bogdanvlviv
ec2e8f645e
Allow :queue option to perform_enqueued_jobs.
If the `:queue` option is specified, then only the job(s) enqueued to
a specific queue will be performed.

Example:
```
def test_perform_enqueued_jobs_with_queue
  perform_enqueued_jobs queue: :some_queue do
    MyJob.set(queue: :some_queue).perform_later(1, 2, 3) # will be performed
    HelloJob.set(queue: :other_queue).perform_later(1, 2, 3) # will not be performed
  end
  assert_performed_jobs 1
end
```

Follow up #33265

[bogdanvlviv & Jeremy Daer]
2018-08-20 00:20:06 +03:00
yuuji.yaginuma
e49fb7921e Increment execution count before deserialize arguments
Currently, the execution count increments after deserializes arguments.
Therefore, if an error occurs with deserialize, it retries indefinitely.

In order to prevent this, the count is moved before deserialize.
Fixes #33344.
2018-08-18 11:22:41 +09:00
bogdanvlviv
f169752163
Add example perform_enqueued_jobs without block to api docs [ci skip]
Follow up #33626
2018-08-16 09:29:30 +03:00
Kevin Deisz
ec16301488
Allow perform_enqueued_jobs to be called without a block.
Performs all of the jobs that have been enqueued up to this point in the test.
2018-08-15 15:00:40 -04:00
Mohit Natoo
39d87a4b7b perform_or_enqueue instead of enqueue_or_perform 2018-08-09 20:33:43 +05:30
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Kasper Timm Hansen
7b3ead3b26
[ci skip] Fixup changelog. Trim title. Mention benefit. 2018-07-20 21:40:53 +02:00
zvkemp
2a1884bfe5 Wrap ActiveJob::Enqueue in evented ActiveSupport::Notification 2018-07-17 15:05:12 -07:00
alpaca-tc
a07354d9eb ActiveJob::Base no longer dependents on Serializers 2018-07-03 21:48:26 +09:00
Kasper Timm Hansen
dca5596f99
Revert "Merge pull request #33234 from alpaca-tc/autoload_activejob_arguments"
It breaks Active Job when run in isolation. E.g. bin/test test/cases/logging_test.rb:
https://travis-ci.org/rails/rails/jobs/398779028

Consider Rafaels suggestion of reviewing the eager loading instead:
https://github.com/rails/rails/pull/33234#issuecomment-401027419

This reverts commit cb0fdaacb277bd0595bfd73178329922aa24477e, reversing
changes made to a0a1abb3c7942084111d87ae95837a83bcc794f6.
2018-07-01 13:22:44 +02:00
bogdanvlviv
22c7d5650c
Allow queue option to assert_no_enqueued_jobs
It can be asserted that no jobs are enqueued to a specific queue:
```ruby
def test_no_logging
  assert_no_enqueued_jobs queue: 'default' do
    LoggingJob.set(queue: :some_queue).perform_later
  end
end
```
2018-06-30 18:30:55 +03:00
Ryuta Kamizono
b3653aee94
Merge pull request #33257 from utilum/ruby-warnings
Fix Ruby warnings tickled by the test suite
2018-06-30 17:58:02 +09:00
utilum
e862ee86b7 Fix Ruby warnings tickled by the test suite 2018-06-30 10:20:45 +02:00
bogdanvlviv
58271f6314
Clarify activejob/lib/active_job/test_helper.rb
Rename `in_block_job` to `enqueued_job` since this variable can refer not only
to jobs that were created in the block.
See #33258.

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

Fix name of tests.
2018-06-29 19:46:55 +03:00
bogdanvlviv
4382fcbc22
Allow call assert_enqueued_with and assert_enqueued_email_with with 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 #33243
2018-06-29 15:37:02 +03:00
Rafael Mendonça França
03fd2f3810
Revert "Merge pull request #33243 from evopark/fix/action-mailer-test-helper-no-block"
This reverts commit 9d6bbf4e0b2d2b2e2fccd87a778de2893bb28a25, reversing
changes made to 5a1ea09062eaed78e21253a128d433a1beb745ad.

This method only works with block.
2018-06-28 15:08:01 +02:00
Marcus Ilgner
3919cb398b
Fix ActionMailer assert_enqueued_email_with
The documentation for assert_enqueued_email_with states that it's
supposed to work without a block yet it calls assert_enqueued_with
which doesn't check whether a block was passed before calling `yield`
2018-06-28 11:01:55 +02:00
alpaca-tc
ff2fbe2708 Autoload ActiveJob::Arguments 2018-06-27 14:53:49 +09:00
alpaca-tc
391015e238 ActiveJob::Arguments is no longer used in file 2018-06-27 14:53:37 +09:00
bogdanvlviv
f1e625f853
Add changelog entry for 3110cae [ci skip]
Since it is changes of the public API, it seems valuable to add a mention
about it to the changelog file.

Follow up 3110caecbebdad7300daaf26bfdff39efda99e25
2018-06-27 00:47:48 +03:00
George Claghorn
3110caecbe Allow passing multiple exceptions to retry_on/discard_on 2018-06-25 18:16:58 -04:00
bogdanvlviv
d6702b7ab2
Fix name of the second parameter of block executed by discard_on and retry_on
[ci skip]

Follow up #32854 and ba07b5fc12a740d41d288bea6347f15f4948483c.
2018-05-29 07:11:33 +00:00
Oscar Amado
ef90adfd27 update README link: md instead rdoc [ci skip] 2018-05-24 17:49:35 +02:00
Oscar Amado
d795e94c45 correct link to activejob readme [ci skip] 2018-05-24 16:39:38 +02:00
utilum
a48f6a5d9f Enable warnings in all test tasks
Also normalize AJ task use t, like all other Rails test tasks.
2018-05-23 23:05:03 +02:00
Kasper Timm Hansen
ba07b5fc12
Rename exception variable to error.
Follows the change from 6fac9bd, so the naming is consistent.
2018-05-21 15:43:16 +02:00
yuuji.yaginuma
6fac9bd599 Pass the error instance as the second parameter of block executed by discard_on
I'm not sure what originally wanted to pass to the argument.
However, as long as see the document added along with the commit, it seems just
to be mistaken that trying to pass the error instance.
https://github.com/rails/rails/pull/30622/files#diff-59beb0189c8c6bc862edf7fdb84ff5a7R64

Fixes #32853
2018-05-12 13:55:25 +09:00
Rafael Mendonça França
5b9cd1a579
Make sure that when serialing an just deserialized job arguments are there
When a job was just deserialized `arguments` is `nil` and the serialized
arguments are in the `@serialized_arguments` variable. If we try to
serialize this job again the arguments are going to be `nil` instead of
what was serialized.

The test we had was not checking this case because it was deserializing
the job in the same object that had the arguments.

To fix this, when the `@serialized_arguments` are present we return it
instead of the result of the `arguments` serialized.
2018-05-01 13:33:50 -04:00