1. 14 4月, 2020 1 次提交
    • É
      Fix perform_enqueued_jobs without a block with other helpers · f123e5e4
      Étienne Barrié 提交于
      assert_enqueued_with with a block ignores all the jobs enqueued before
      the block for its assertions by counting the number of jobs and dropping
      the n first elements from the Array, but since we're now mutating the
      Array in perform_enqueued_jobs without a block, it's broken.
      
      This uses another implementation which is correct when the array is
      mutated, by getting a duplicated array of jobs, then removing them from
      the original array.
      
      Similarly assert_enqueued_jobs with a block was using counts only, now
      keeps track of the specific jobs to count them at the end.
      f123e5e4
  2. 17 3月, 2020 2 次提交
  3. 10 3月, 2020 2 次提交
    • E
      AJ `perform_enqueued_jobs` shouldn't perform job retries: · 17e304de
      Edouard CHIN 提交于
      - ### Problem
      
        If we use `perform_enqueued_jobs` without a block, a job that
        uses a retry mechanism to reeenqueue itself would get performed
        right away.
        This behaviour make sense when using `perform_enqueued_jobs` with
        a block.
      
        However I'm expecting `perform_enqueued_jobs` without a block to
        perform jobs that are **already** in the queue not the ones that
        will get enqueued afterwards.
      
        ### Solution
      
        Dup the array of jobs given to avoid future mutation.
      17e304de
    • E
      Fix AJ `TestAdapter#performed_jobs` not properly counting job: · 13cb5b78
      Edouard CHIN 提交于
      - ### Problem
      
        If we use `perform_enqueued_jobs` without a block,
        a job that raises an error wouldn't be appended to
        the list of `performed_jobs`.
      
        ### Solution
      
        Push the job in the array before it is actually performed.
      13cb5b78
  4. 28 2月, 2020 1 次提交
  5. 11 2月, 2020 1 次提交
    • E
      Fix ActiveJob Test adapter not respecting retry attempts: · d35cf4c0
      Edouard CHIN 提交于
      - ### Problem
      
        Given the below example the test adapter will retry the job
        indefinitely:
      
        ```ruby
          class BuggyJob < ActiveJob::Base
            retry_on(Exception,  attempts: 2)
      
            def perform
              raise "error"
            end
          end
      
          BuggyJob.perform_later
          perform_enqueued_jobs
        ```
      
        The problem is that when the job get retried, the
        `exception_executions` variable is not serialized/deserialized,
        resulting in ActiveJob to not be able to determine how many time
        this job was retried.
      
        The solution in this PR is to deserialize the whole job in the test
        adapter, and reserialize it before retrying.
      
        Fix #38391
      d35cf4c0
  6. 13 8月, 2019 1 次提交
  7. 06 8月, 2019 1 次提交
    • J
      Add at option to perform_enqueued_jobs test helper · 647317d1
      John Crepezzi 提交于
      Currently, the `perform_enqueued_jobs` helpers will also immediately
      perform jobs that are scheduled via `set(wait:)` to run in the future.
      This commit adds a new argument to `perform_enqueued_jobs` to make it
      only run jobs scheduled at or before the passed in `Time`. This allows
      testing the side effects of immediate job execution separate of jobs
      delayed in the future.
      647317d1
  8. 26 7月, 2019 1 次提交
    • V
      Ability to test activejobs with relative delay · 10d0f48a
      Vlado Cingel 提交于
      `assert_enqueued_with` and `assert_performed_with` were not able to
      properly test jobs with relative delay. `:at` option was asserted for
      equality and test will always fail cause small fraction of time will
      pass between job call and assertion.
      
      This commit fixes that by droping microseconds from `:at` argument
      assertions.
      10d0f48a
  9. 25 3月, 2019 1 次提交
  10. 23 3月, 2019 1 次提交
  11. 29 1月, 2019 1 次提交
  12. 22 11月, 2018 1 次提交
  13. 13 10月, 2018 1 次提交
    • A
      Include deserialized arguments in jobs returned by AJ test helpers · 3ebc2290
      Alan Wu 提交于
      `assert_enqueued_with` and `assert_performed_with` return a instantiated
      instance of the matching job for further assertion (#21010).
      
      Before this commit the `arguments` method on the returned instance
      returns a serialized version of the arguments.
      3ebc2290
  14. 27 9月, 2018 1 次提交
    • E
      Add a way to check for subset of arguments when performing jobs: · 4d75f589
      Edouard CHIN 提交于
      - When calling `assert_performed_with`/`assert_enqueued_with`, the
        +args+ needs to match exactly what the job get passed.
      
        Some jobs can have lot of arguments, or even a simple hash argument
        has many key. This is not convenient to test as most tests doesn't
        need to check if the arguments matches perfectly.
      
        This PR make it possible to only check if a subset of arguments were
        passed to the job.
      4d75f589
  15. 26 9月, 2018 1 次提交
  16. 21 9月, 2018 1 次提交
  17. 12 9月, 2018 1 次提交
  18. 22 8月, 2018 1 次提交
    • U
      Remove duplicate test · 96ac7e4c
      utilum 提交于
      This patch corrects a duplicate method name introduced in #33635.
      
      Also fixes typo in method names.
      96ac7e4c
  19. 20 8月, 2018 5 次提交
    • B
      Allow `assert_performed_with` to be called without a block. · 2ec60fb8
      bogdanvlviv 提交于
      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.
      2ec60fb8
    • B
      Fix `assert_performed_jobs` and `assert_no_performed_jobs` · 11634e8e
      bogdanvlviv 提交于
      Execution of `assert_performed_jobs`, and `assert_no_performed_jobs`
      without a block should respect passed `:except`, `:only`, and `:queue` options.
      11634e8e
    • B
      Allow `:queue` option to `assert_no_performed_jobs`. · de4420da
      bogdanvlviv 提交于
      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
      ```
      de4420da
    • B
      Allow `:queue` option to `assert_performed_jobs`. · d50fb21e
      bogdanvlviv 提交于
      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
      ```
      d50fb21e
    • B
      Allow `:queue` option to `perform_enqueued_jobs`. · ec2e8f64
      bogdanvlviv 提交于
      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]
      ec2e8f64
  20. 16 8月, 2018 1 次提交
  21. 30 6月, 2018 2 次提交
    • B
      Allow `queue` option to `assert_no_enqueued_jobs` · 22c7d565
      bogdanvlviv 提交于
      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
      ```
      22c7d565
    • B
      Clarify activejob/lib/active_job/test_helper.rb · 58271f63
      bogdanvlviv 提交于
      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.
      58271f63
  22. 29 6月, 2018 1 次提交
    • B
      Allow call `assert_enqueued_with` and `assert_enqueued_email_with` with no block · 4382fcbc
      bogdanvlviv 提交于
      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
      4382fcbc
  23. 20 7月, 2017 1 次提交
  24. 18 7月, 2017 1 次提交
  25. 11 7月, 2017 1 次提交
  26. 10 7月, 2017 1 次提交
  27. 02 7月, 2017 1 次提交
  28. 01 7月, 2017 1 次提交
  29. 16 3月, 2017 1 次提交
  30. 01 2月, 2017 1 次提交
    • Y
      correctly set test adapter when configure the queue adapter on a per job (#26690) · 80dc3098
      Yuji Yaginuma 提交于
      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
      80dc3098
  31. 31 1月, 2017 1 次提交
  32. 18 1月, 2017 1 次提交
  33. 25 12月, 2016 1 次提交