1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/test/helper.rb
Edouard CHIN 9eb4b4ed01 Fix deprecation being thrown at boot time:
-
  ### Problem

  In rails/rails@bbfab0b33a I introduced a change which outputs
  a deprecation whenever a class inherits from ActiveJob::Base.

  This has the negative effect to trigger a massive amount of
  deprecation at boot time especially if your app is eagerloaded
  (like it's usually the case on CI).

  Another issue with this approach was that the deprecation will
  be output no matter if a job define a `after_perform` callbacks
  i.e.
  ```ruby
    class MyJob < AJ::Base
      before_enqueue { throw(:abort) }
    end

    # This shouldn't trigger a deprecation since no after callbacks are defined
    # The change in 6.2 will be already safe for the app.
  ```

  ### Solution

  Trigger the deprecation only when a job is abort
  (during enqueuing or performing) AND a `after_perform`
  callback is defined on the job.
2019-12-13 03:25:03 +01:00

21 lines
472 B
Ruby

# frozen_string_literal: true
require "active_job"
require "support/job_buffer"
GlobalID.app = "aj"
@adapter = ENV["AJ_ADAPTER"] ||= "inline"
puts "Using #{@adapter}"
if ENV["AJ_INTEGRATION_TESTS"]
require "support/integration/helper"
else
ActiveJob::Base.logger = Logger.new(nil)
ActiveJob::Base.skip_after_callbacks_if_terminated = true
require "adapters/#{@adapter}"
end
require "active_support/testing/autorun"
require_relative "../../tools/test_common"