aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Allow call `assert_enqueued_with` and `assert_enqueued_email_with` with no blockbogdanvlviv2018-06-291-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Merge pull request #33243 from ↵Rafael Mendonça França2018-06-281-1/+1
| | | | | | | | | evopark/fix/action-mailer-test-helper-no-block" This reverts commit 9d6bbf4e0b2d2b2e2fccd87a778de2893bb28a25, reversing changes made to 5a1ea09062eaed78e21253a128d433a1beb745ad. This method only works with block.
* Fix ActionMailer assert_enqueued_email_withMarcus Ilgner2018-06-281-1/+1
| | | | | | 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`
* Autoload ActiveJob::Argumentsalpaca-tc2018-06-271-0/+1
|
* ActiveJob::Arguments is no longer used in filealpaca-tc2018-06-272-3/+0
|
* Allow passing multiple exceptions to retry_on/discard_onGeorge Claghorn2018-06-251-7/+7
|
* Fix name of the second parameter of block executed by `discard_on` and ↵bogdanvlviv2018-05-291-4/+4
| | | | | | | | `retry_on` [ci skip] Follow up #32854 and ba07b5fc12a740d41d288bea6347f15f4948483c.
* update README link: md instead rdoc [ci skip]Oscar Amado2018-05-241-1/+1
|
* correct link to activejob readme [ci skip]Oscar Amado2018-05-241-1/+1
|
* Pass the error instance as the second parameter of block executed by ↵yuuji.yaginuma2018-05-121-1/+1
| | | | | | | | | | | `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
* Make sure that when serialing an just deserialized job arguments are thereRafael Mendonça França2018-05-011-4/+16
| | | | | | | | | | | | | 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.
* Strip duplicated suffixes more strictlyRyuta Kamizono2018-04-221-1/+1
| | | | In the previous code incorrectly removes intermediate words.
* Fix duplicated suffix for JobGeneratorYoshiyuki Hirano2018-04-221-0/+4
|
* fix spelling in docs for ActiveJob::Serializers::ObjectSerializer#deserializeJared Rader2018-04-131-1/+1
|
* Remove support for Qu gem.Alberto Almagro2018-03-192-49/+0
| | | | | | Reasons are that the Qu gem wasn't compatible since Rails 5.1, gem development was stopped in 2014 and maintainers have confirmed its demise. See issue #32273
* Add documentation about not accepting PRs for new adapters (#32298)Jeremy Green2018-03-191-0/+1
|
* Remove passing extra arguments to ActiveJob Callbacksbogdanvlviv2018-02-233-4/+4
|
* Add support for timezones to Active JobAndrew White2018-02-223-1/+21
| | | | | | Record what was the current timezone in effect when the job was enqueued and then restore when the job is executed in same way that the current locale is recorded and restored.
* Merge pull request #32026 from bogdanvlviv/improve-30941Rafael França2018-02-203-24/+47
|\ | | | | Improve ActiveJob custom argument serializers #30941
| * Fix error message about unknown `ActiveJob` argument serializerbogdanvlviv2018-02-171-1/+1
| |
| * Fix docs of ActiveJob custom argument serializersbogdanvlviv2018-02-172-22/+22
| | | | | | | | | | | | Add `:nodoc:` to `ActiveJob::Serializers` Add `:doc:` to `ActiveJob::Serializers::ObjectSerializer#klass` Express `ActiveJob::Serializers::ObjectSerializer#klass` as private method
| * Add argument serializer `TimeWithZoneSerializer`bogdanvlviv2018-02-172-1/+24
| | | | | | | | | | The serializer serializes an instance of `ActiveSupport::TimeWithZone`. The serializer deserializes value to `ActiveSupport::TimeWithZone` if possible.
* | Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-172-4/+2
|/ | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Fix custome serializer settingYuji Yaginuma2018-02-162-4/+9
| | | | | | | | The serializer should be set up in `after_initialize` so that it work properly even if the user specifies serializer with initializers. Also, since `custom_serializers` is `Array`, it needs to be flattened before setting the value.
* Simplify the implementation of custom argument serializersRafael Mendonça França2018-02-1410-272/+172
| | | | | | | | | | | | | We can speed up things for the supported types by keeping the code in the way it was. We can also avoid to loop trough all serializers in the deserialization by trying to access the class already in the Hash. We could also speed up the custom serialization if we define the class that is going to be serialized when registering the serializers, but that will remove the possibility of defining a serialzer for a superclass and have the subclass serialized using it.
* Improve documentation on custom serializersRafael Mendonça França2018-02-142-0/+25
|
* Add configuration to set custom serializersRafael Mendonça França2018-02-141-0/+6
|
* No need to require a autoloaded constantRafael Mendonça França2018-02-141-1/+0
|
* Add serializers for Time, Date and DateTimeRafael Mendonça França2018-02-146-1/+74
|
* Allow serializers to be used either as classes or objectsRafael Mendonça França2018-02-149-115/+103
|
* Add symbol and duration serializersRafael Mendonça França2018-02-143-1/+50
|
* Only add one more custom key in the serialized hashRafael Mendonça França2018-02-145-43/+36
| | | | | | | Now custom serialziers can register itself in the serialized hash using the "_aj_serialized" key that constains the serializer name. This way we can avoid poluting the hash with many reserved keys.
* Define the interface of a SerializerRafael Mendonça França2018-02-141-0/+18
|
* Remove unnecessary qualified constant lookupsRafael Mendonça França2018-02-145-11/+11
|
* Simplify the implementation of custom serialziersRafael Mendonça França2018-02-142-36/+28
| | | | | Right now it is only possible to define serializers globally so we don't need to use a class attribute in the job class.
* Remove non-default serializersEvgenii Pecherkin2018-02-146-148/+7
|
* Introduce serializers to ActiveJobEvgenii Pecherkin2018-02-1416-131/+470
|
* Start Rails 6.0 development!!!Rafael Mendonça França2018-01-301-3/+3
| | | | :tada::tada::tada:
* Merge pull request #30622 from aidanharan/custom-discarded-job-handlingRafael França2018-01-231-1/+11
|\ | | | | Allow for custom handling of exceptions that are discarded
| * Merge branch 'master' into custom-discarded-job-handlingAidan Haran2017-12-0910-19/+29
| |\
| * | Allow for custom handling of exceptions that are discardedAidan Haran2017-09-161-1/+11
| | |
* | | Consolidate `queue_adapter=` and `interpret_adapter`Ryuta Kamizono2018-01-051-18/+12
| | | | | | | | | | | | | | | Since #25037, `queue_adapter=` simply delegates to `interpret_adapter` only.
* | | Bump license years for 2018Yoshiyuki Hirano2017-12-311-1/+1
| | |
* | | [ci skip] Add a space to comment in SidekiqAdapterYoshiyuki Hirano2017-12-141-1/+1
| |/ |/| | | | | | | * I think it's better to have a leading space after the `#` denoting the start of the comment.
* | Fix example code in ActiveJob::Core [ci skip]Yoshiyuki Hirano2017-12-051-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) It seems that it raise error on example code in `ActiveJob::Core`. Before: ```ruby class DeliverWebhookJob < ActiveJob::Base def serialize super.merge('attempt_number' => (@attempt_number || 0) + 1) end def deserialize(job_data) super @attempt_number = job_data['attempt_number'] end rescue_from(Timeout::Error) do |exception| raise exception if @attempt_number > 5 retry_job(wait: 10) end def perform raise Timeout::Error end end ``` Then it run `DeliverWebhookJob.perform_now` in `rails console`. And raise error: NoMethodError: undefined method `>' for nil:NilClass from /app/jobs/deliver_webhook_job.rb:12:in `block in <class:DeliverWebhookJob>' So I thought it's necessary to fix it. After: ```ruby class DeliverWebhookJob < ActiveJob::Base attr_writer :attempt_number def attempt_number @attempt_number ||= 0 end def serialize super.merge('attempt_number' => attempt_number + 1) end def deserialize(job_data) super self.attempt_number = job_data['attempt_number'] end rescue_from(Timeout::Error) do |exception| raise exception if attempt_number > 5 retry_job(wait: 10) end def perform raise Timeout::Error end end ``` Then it run `DeliverWebhookJob.perform_now` in `rails console`. And it does'nt raise error NoMethodError. 2) Use `Timeout::Error` instead of `TimeoutError` (`TimeoutError` is deprecated).
* | Preparing for 5.2.0.beta2 releaseRafael Mendonça França2017-11-281-1/+1
| |
* | Preparing for 5.2.0.beta1 releaseRafael Mendonça França2017-11-271-1/+1
| |
* | Improve DelayedJob wrapper loggingJacek Lachowski2017-11-241-0/+4
| | | | | | | | | | | | | | | | ActiveJob wraps every adapter into its own class, that is later passed into DelayedJob which is responsible for displaying all the logs. This change improves the logging so we can easily trace executed jobs and see meaningful information in the logs.
* | Use .tt extension to all the template filesRafael Mendonça França2017-11-132-0/+0
| | | | | | | | | | | | | | | | Make clear that the files are not to be run for interpreters. Fixes #23847. Fixes #30690. Closes #23878.
* | [Active Job] require_relative => requireAkira Matsuda2017-10-214-13/+13
| | | | | | | | This basically reverts fef234f1f0a238c2277459652861144ae89501ff