aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test
Commit message (Collapse)AuthorAgeFilesLines
...
* 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 ```
* Merge pull request #33257 from utilum/ruby-warningsRyuta Kamizono2018-06-302-4/+6
|\ | | | | Fix Ruby warnings tickled by the test suite
| * Fix Ruby warnings tickled by the test suiteutilum2018-06-302-4/+6
| |
* | 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-252-0/+25
|
* Rename exception variable to error.Kasper Timm Hansen2018-05-211-2/+2
| | | | Follows the change from 6fac9bd, so the naming is consistent.
* Pass the error instance as the second parameter of block executed by ↵yuuji.yaginuma2018-05-122-2/+2
| | | | | | | | | | | `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.
* Remove support for Qu gem.Alberto Almagro2018-03-193-46/+1
| | | | | | 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 support for timezones to Active JobAndrew White2018-02-226-0/+74
| | | | | | 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-232-0/+9
|\ | | | | Allow for custom handling of exceptions that are discarded
| * Merge branch 'master' into custom-discarded-job-handlingAidan Haran2017-12-098-22/+19
| |\
| * | Allow for custom handling of exceptions that are discardedAidan Haran2017-09-162-0/+9
| | |
* | | Explicitly require `sidekiq/cli`yuuji.yaginuma2017-12-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, sidekiq integration test + Ruby 2.5.0-rc1 show exception as follows. ``` #<Thread:0x000000000670bec0@/home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:23 run> terminated with exception (report_on_exception is true): /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant Sidekiq::CLI (NameError) from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache' from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `rescue in load_missing_constant' from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:42:in `load_missing_constant' from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/launcher.rb:65:in `heartbeat' from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/launcher.rb:123:in `start_heartbeat' ``` https://travis-ci.org/rails/rails/jobs/317187279#L2152 The reason for this is that `Sidekiq::CLI` has not been loaded. Sidekiq integration test launches a Sidekiq instance within another Ruby process. In such a case, need to require 'sidekiq/cli' in that launch code. Ref: https://github.com/mperham/sidekiq/pull/3692#issuecomment-352032251
* | | 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.
* | | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-1/+1
| |/ |/| | | | | Follow up of #31432.
* | Improve DelayedJob wrapper loggingJacek Lachowski2017-11-241-0/+7
| | | | | | | | | | | | | | | | 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.
* | Make sidekiq and resque integration tests work in CIyuuji.yaginuma2017-11-132-9/+1
| | | | | | | | | | | | | | | | | | | | Since 8f2490b, the integration test of sidekiq and resque is not working in CI. https://travis-ci.org/rails/rails/jobs/301276197#L2055 https://travis-ci.org/rails/rails/jobs/301276197#L2061 Because 8f2490b removed password from `redis-server`. So must also remove passwords from these tests.
* | Return a non zero code when can not connect to redis in CIyuuji.yaginuma2017-11-132-2/+4
| |
* | `rails new` runs `rails active_storage:install`bogdanvlviv2017-11-062-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests AppGeneratorTest#test_config_jdbcmysql_database rails aborted! LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (compressed) bin/rails:4:in `<main>' Tasks: TOP => activestorage:install => environment (See full trace by running task with --trace) AppGeneratorTest#test_config_jdbc_database rails aborted! LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (compressed) bin/rails:4:in `<main>' Tasks: TOP => activestorage:install => environment (See full trace by running task with --trace) AppGeneratorTest#test_shebang_is_added_to_rails_file /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError) Prevent PendingMigrationError in tests * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError * FileUtils.rm_r("db/migrate") * --skip-active-storage Fix failed tests in `railties/test/railties/engine_test.rb` Related to #30111 Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed` - Explicitly skip active_storage - Ensure that skipped frameworks are commented - Ensure that default frameworks are not commented Fix error `Errno::ENOSPC: No space left on device - sendfile` Since `rails new` runs `rails active_storage:install` that boots an app. Since adding Bootsnap 0312a5c67e35b960e33677b5358c539f1047e4e1 during booting an app, it creates the cache: 264K tmp/cache/bootsnap-load-path-cache 27M tmp/cache/bootsnap-compile-cache * teardown_app must remove app
* | removed unnecessary returnsShuhei Kitagawa2017-10-281-1/+1
| |
* | Merge pull request #30750 from k2nr/fix-active-jobRyuta Kamizono2017-10-132-2/+2
|\ \ | | | | | | Yield with an error instance instead of error class
| * | Test exception message to ensure an exception instance is yieldedKazunori Kajihiro2017-10-132-2/+2
| |/
* / redis-rb 4.0 supportJeremy Daer2017-10-081-7/+4
|/ | | | | | | | * Use `gem 'redis', '~> 4.0'` for new app Gemfiles * Loosen Action Cable redis-rb dep to `>= 3.3, < 5` * Bump redis-namespace for looser Redis version dep * Avoid using the underlying `redis.client` directly * Use `Redis.new` instead of `Redis.connect`
* Use `ActiveJob::Base.queue_adapter_name` to get adapter nameyuuji.yaginuma2017-08-171-3/+1
| | | | Since 673606a, it holds adapter name.
* Wait for the Delayed Job worker thread to finishMatthew Draper2017-08-131-0/+1
|
* Use File::NULL instead of "/dev/null"Kazuhiro NISHIYAMA2017-07-311-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-1165-0/+65
|
* Make sidekiq and resque integration tests work in CIyuuji.yaginuma2017-07-102-1/+9
| | | | | | | | | Since f55ecc6, the integration test of sidekiq and resque is not working in CI. https://travis-ci.org/rails/rails/jobs/251783876 Because f55ecc6 required a password to access redis. Therefore, handling by passing passwords when connecting to redis.
* Use frozen-string-literal in ActiveJobKir Shatrov2017-07-0965-0/+65
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0265-65/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-0165-0/+65
|