Commit Graph

22 Commits

Author SHA1 Message Date
Jean Boussier
b6d3a478fa Make assert_enqueued_with and assert_performed_with returns the matched job 2015-08-10 20:14:42 -04:00
Johannes Opper
3860e6b2bf Fixes #20799
When `#perform_later` is called the locale isn't stored on the
queue, which results in a locale reset when the job is performed.

An example of the problem:

    I18n.locale = 'de'
    HelloJob.perform_now # german message, correct

but

    I18n.locale = 'de'
    HelloJob.perform_later # english message, incorrect

This PR attaches the current I18n.locale to every job during the
serialization process. It is then restored during deserialization
and used to perform the job with the correct locale.

It falls back to the default locale if no serialized locale is
found in order to provide backward compatibility with previously
stored jobs. It is not necessary to clear the queue for the update.
2015-08-04 00:38:18 +02:00
Yves Senn
b25436abc4 minor formatting changes in changelogs. [ci skip] 2015-05-31 11:24:36 +02:00
Prathamesh Sonpatki
daba090dec Pass over CHANGELOGS [ci skip] 2015-05-16 11:00:17 +05:30
Kevin Deisz
221a411fd7 Provide provider_job_id to qu adapter.
Further work to provide provider_job_id for queue adapters.
2015-05-07 19:17:22 -04:00
Jeroen van Baarsen
29fcbc2ea0 Make que report back its job_id to provider_job_id
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-05-07 21:59:07 +02:00
Jeroen van Baarsen
52d131826e Let Sidekiq set provider_job_id
When a job is added to Sidekiq by ActiveJob, make sure we still can get the
original job_id provider by Sidekiq. We do this by adding the sidekiq jid to
provider_job_id field on the job object.

Partly fixes #18821

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-05-07 21:48:50 +02:00
Kevin Deisz
dd8e859829 Get provider_job_id from DelayedJob
When queueing with DelayedJob, get the id of the job instance and report
it back to ActiveJob as provider_job_id.
2015-05-05 10:30:16 -04:00
Yves Senn
4d4950fae9 Merge pull request #19969 from y-yagi/fix_job_helper_method
match a expected value with message of `assert_equal` in AJ helper methods
2015-05-01 08:59:58 +02:00
Matthew Draper
cb01246721 Merge pull request #19034 from jvanbaarsen/explicit-job-base-class
Add explicit base class for ActiveJob jobs
2015-03-30 23:04:25 +10:30
Jeroen van Baarsen
929a794a31 Add explicit base class for ActiveJob jobs
* Jobs generated now inherent from ApplicationJob
* ApplicationJob inherents from ActiveJob::Base
* Added entry to changelog

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-03-23 22:37:11 +01:00
Carlos Antonio da Silva
de9a3748c4 Move #18833 changelog to the top [ci skip] 2015-02-08 11:52:47 -02:00
Michael Ryan
e818f65770 Add an :only option to perform_enqueued_jobs to filter jobs based on
type.

This allows specific jobs to be tested, while preventing others from
being performed unnecessarily.

Example:

    def test_hello_job
      assert_performed_jobs 1, only: HelloJob do
        HelloJob.perform_later('jeremy')
        LoggingJob.perform_later
      end
    end

An array may also be specified, to support testing multiple jobs.

Example:

    def test_hello_and_logging_jobs
      assert_nothing_raised do
        assert_performed_jobs 2, only: [HelloJob, LoggingJob] do
          HelloJob.perform_later('jeremy')
          LoggingJob.perform_later('stewie')
          RescueJob.perform_later('david')
        end
      end
    end

Fixes #18802.

Trim space and document :only option.
2015-02-06 14:11:42 -05:00
Sean Griffin
31085a5cd4 Allow keyword arguments to work with ActiveJob
Unfortunately, the HashWithIndifferent access approach is insufficient
for our needs. It's perfectly reasonable to want to use keyword
arguments with Active Job, which we will see as a symbol keyed hash. For
Ruby to convert this back to keyword arguments, it must deserialize to a
symbol keyed hash.

There are two primary changes to the serialization behavior. We first
treat a HWIA separately, and mark it as such so we can convert it back
into a HWIA during deserialization.

For normal hashes, we keep a list of all symbol keys, and convert them
back to symbol keys after deserialization.

Fixes #18741.
2015-01-30 13:43:39 -07:00
Yves Senn
a7621d7d53 formatting pass over CHANGELOGs. [ci skip] 2015-01-10 12:17:57 +01:00
Carlos Antonio da Silva
a22a653c29 Fix Active Job changelog formatting and reword a bit [ci skip] 2015-01-08 07:40:00 -02:00
George Claghorn
b5e88317cc Add :only option to assert_enqueued_jobs
With the option, assert_enqueued_jobs will check the number of times a specific kind of job is enqueued.
2015-01-07 23:44:08 -05:00
Robin Dupret
f2b31cd6d1 Tiny follow-up to #18260 [ci skip]
Indent the list content by 4 spaces instead of 2 to match the other
changelog files. Also wrap the lines around 80 chars.

Finally update the documentation example with nit-picky things.
2014-12-31 17:35:41 +01:00
Prathamesh Sonpatki
c8e4d0a0a1 Fixed typo in ActiveJob CHANGELOG [ci skip] 2014-12-31 21:59:37 +05:30
Isaac Seymour
65542e2797 ActiveJob: delegate full deserialization to class 2014-12-30 23:33:09 +00:00
Rafael Mendonça França
f25ad07f5a Start Rails 5 development 🎉
We will support only Ruby >= 2.1.

But right now we don't accept pull requests with syntax changes to drop
support to Ruby 1.9.
2014-11-28 15:00:06 -02:00
Abdelkader Boudih
a75f085941 Add 'activejob/' from commit '14f74a8331f94150dfee653224de8fc837797709'
git-subtree-dir: activejob
git-subtree-mainline: b45b99894a60eda434abec94d133a1cfd8de2dda
git-subtree-split: 14f74a8331f94150dfee653224de8fc837797709
2014-08-12 09:17:19 +00:00