aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/cases
Commit message (Collapse)AuthorAgeFilesLines
* Remove duplicate testutilum2018-08-221-2/+2
| | | | | | This patch corrects a duplicate method name introduced in #33635. Also fixes typo in method names.
* Allow `assert_performed_with` to be called without a block.bogdanvlviv2018-08-201-7/+91
| | | | | | | | | | | | | | | 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.
* Fix `assert_performed_jobs` and `assert_no_performed_jobs`bogdanvlviv2018-08-201-10/+256
| | | | | Execution of `assert_performed_jobs`, and `assert_no_performed_jobs` without a block should respect passed `:except`, `:only`, and `:queue` options.
* Allow `:queue` option to `assert_no_performed_jobs`.bogdanvlviv2018-08-201-0/+54
| | | | | | | | | | | | | | 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 ```
* Allow `:queue` option to `assert_performed_jobs`.bogdanvlviv2018-08-201-0/+58
| | | | | | | | | | | | | | | 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 ```
* Allow `:queue` option to `perform_enqueued_jobs`.bogdanvlviv2018-08-201-5/+139
| | | | | | | | | | | | | | | | | | | | 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]
* Increment execution count before deserialize argumentsyuuji.yaginuma2018-08-181-0/+8
| | | | | | | | 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.
* Allow `perform_enqueued_jobs` to be called without a block.Kevin Deisz2018-08-151-2/+18
| | | | Performs all of the jobs that have been enqueued up to this point in the test.
* Wrap ActiveJob::Enqueue in evented ActiveSupport::Notificationzvkemp2018-07-171-3/+20
|
* Allow `queue` option to `assert_no_enqueued_jobs`bogdanvlviv2018-06-301-0/+73
| | | | | | | | | | | 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 ```
* Clarify activejob/lib/active_job/test_helper.rbbogdanvlviv2018-06-291-2/+8
| | | | | | | | | | | 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.
* Allow call `assert_enqueued_with` and `assert_enqueued_email_with` with no blockbogdanvlviv2018-06-291-9/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Allow passing multiple exceptions to retry_on/discard_onGeorge Claghorn2018-06-251-0/+18
|
* 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-6/+6
| | | | | | | | | | | | | 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.
* Add support for timezones to Active JobAndrew White2018-02-222-0/+31
| | | | | | 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-202-1/+9
|\ | | | | Improve ActiveJob custom argument serializers #30941
| * Fix error message about unknown `ActiveJob` argument serializerbogdanvlviv2018-02-171-1/+1
| |
| * Add argument serializer `TimeWithZoneSerializer`bogdanvlviv2018-02-171-0/+8
| | | | | | | | | | The serializer serializes an instance of `ActiveSupport::TimeWithZone`. The serializer deserializes value to `ActiveSupport::TimeWithZone` if possible.
* | Fix "warning: BigDecimal.new is deprecated"yuuji.yaginuma2018-02-181-1/+1
|/
* Add tests to serialize and deserialze individuallyRafael Mendonça França2018-02-141-0/+43
| | | | | This will make easier to be backwards compatible when changing the serialization implementation.
* Simplify the implementation of custom argument serializersRafael Mendonça França2018-02-142-3/+20
| | | | | | | | | | | | | 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.
* Add serializers for Time, Date and DateTimeRafael Mendonça França2018-02-141-1/+3
|
* Allow serializers to be used either as classes or objectsRafael Mendonça França2018-02-141-9/+7
|
* Add symbol and duration serializersRafael Mendonça França2018-02-141-1/+2
|
* Only add one more custom key in the serialized hashRafael Mendonça França2018-02-141-8/+23
| | | | | | | 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.
* Simplify the implementation of custom serialziersRafael Mendonça França2018-02-141-5/+9
| | | | | 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-142-7/+65
|
* Introduce serializers to ActiveJobEvgenii Pecherkin2018-02-141-2/+8
|
* Merge pull request #30622 from aidanharan/custom-discarded-job-handlingRafael França2018-01-231-0/+7
|\ | | | | Allow for custom handling of exceptions that are discarded
| * Merge branch 'master' into custom-discarded-job-handlingAidan Haran2017-12-091-1/+1
| |\
| * | Allow for custom handling of exceptions that are discardedAidan Haran2017-09-161-0/+7
| | |
* | | Suppress `warning: BigDecimal.new is deprecated`Yasuo Honda2017-12-151-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `BigDecimal.new` has been deprecated in BigDecimal 1.3.3 which will be a default for Ruby 2.5. Refer https://github.com/ruby/bigdecimal/commit/533737338db915b00dc7168c3602e4b462b23503 * This commit has been made as follows: ``` cd rails git grep -l BigDecimal.new | grep -v guides/source/5_0_release_notes.md | grep -v activesupport/test/xml_mini_test.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g" ``` - `activesupport/test/xml_mini_test.rb` Editmanually to remove `.new` and `::` - guides/source/5_0_release_notes.md This is a Rails 5.0 release notes.
* | Test exception message to ensure an exception instance is yieldedKazunori Kajihiro2017-10-131-1/+1
|/
* Use `ArgumentError` instead of own error classyuuji.yaginuma2017-07-201-17/+17
| | | | | If the argument is invalid, I think that it is more intuitive to use `ArgumentError` than its own error class.
* Add `except` option for ActiveJob::TestHelper methodsposthumanism2017-07-181-0/+359
|
* [Active Job] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-1114-0/+14
|
* Use frozen-string-literal in ActiveJobKir Shatrov2017-07-0914-0/+14
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0214-14/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-0114-0/+14
|
* ActiveJob::Core#serialize stores provider_job_id (fixes #26581).utilum2017-06-271-0/+8
|
* Removed string inquiry.Mohit Natoo2017-05-261-2/+2
| | | | | | fixed indentation. rebased with master.
* Provides friendlier way to access queue adapters of a job.Mohit Natoo2017-05-261-1/+6
| | | | - removed predicate method. Used only reader.
* Add missing requireyuuji.yaginuma2017-04-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Without this, unit test fails. ``` bundle exec ruby -w -Ilib:lib:test test/cases/logging_test.rb Using inline Run options: --seed 41246 # Running: SE......S.... Finished in 0.052938s, 245.5696 runs/s, 831.1585 assertions/s. 1) Error: LoggingTest#test_job_error_logging: NameError: uninitialized constant LoggingTest::RescueJob test/cases/logging_test.rb:130:in `rescue in test_job_error_logging' test/cases/logging_test.rb:129:in `test_job_error_logging' 13 runs, 44 assertions, 0 failures, 1 errors, 2 skips You have skipped tests. Run with --verbose for details. ```
* Add error logging to Active JobSteven Bull2017-03-271-0/+7
| | | | | | | | | | | | | | | | | | | | Active Job logging instrumentation is changed to log errors (with backtrace) when a job raises an exception in #perform. This improves debugging during development and test with the default configuration. Prior to Rails 5, the default development configuration ran jobs with InlineAdapter, which would raise exceptions to the caller and be shown in the development log. In Rails 5, the default adapter was changed to AsyncAdapter, which would silently swallow exceptions and log a "Performed SomeJob from Async..." info message. This could be confusing to a developer, as it would seem that the job was performed successfully. This patch removes the "Performed..." info message from the log and adds an error-level "Error performing SomeJob..." log message which includes the exception backtrace for jobs that raise an exception within the #perform method. It provides this behavior for all adapters.
* Revert #27850 following test breakage (#28427)David Heinemeier Hansson2017-03-151-11/+0
|
* Include JobID in all ActiveJob info logsBolek Kurowski2017-02-221-6/+6
| | | | | | | | | | Currently we provide the Job ID in logs only related to enqueuing a job. This adds the job id to the remaining ActiveJob logs when: - a job started performing - a job ended performing Providing the job id in those logs will ease searching logs by job id.
* correctly set test adapter when configure the queue adapter on a per job ↵Yuji Yaginuma2017-01-312-0/+18
| | | | | | | | | | | | (#26690) The `ActiveJob::TestHelper` replace the adapter to test adapter in `before_setup`. It gets the target class using the `descendants`, but if the test target job class is not loaded, will not be a replacement of the adapter. Therefore, instead of replacing with `before_setup`, modified to replace when setting adapter. Fixes #26360
* Append skipped jobs to enqueued_jobsAlexander Pauly2017-01-311-0/+11
| | | | | | | | | | Refactored ActiveJob TestAdapter Updated ActiveJob changelog Fixed typo in changelog Fixed formatting issue in changelog
* assert_enqueued_jobs with queue optionMichael Elfassy2017-01-181-0/+21
|