2015-12-31 15:33:35 -08:00
|
|
|
# frozen_string_literal: true
|
2019-04-01 18:20:41 +02:00
|
|
|
|
|
|
|
require "sidekiq/testing"
|
2012-05-01 15:54:04 -07:00
|
|
|
|
2013-09-20 14:39:11 -07:00
|
|
|
##
|
|
|
|
# The Sidekiq inline infrastructure overrides perform_async so that it
|
2022-03-03 12:37:25 -08:00
|
|
|
# actually calls perform instead. This allows jobs to be run inline in a
|
2013-09-20 14:39:11 -07:00
|
|
|
# testing environment.
|
|
|
|
#
|
|
|
|
# This is similar to `Resque.inline = true` functionality.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
#
|
|
|
|
# require 'sidekiq/testing/inline'
|
|
|
|
#
|
|
|
|
# $external_variable = 0
|
|
|
|
#
|
2022-03-03 12:37:25 -08:00
|
|
|
# class ExternalJob
|
|
|
|
# include Sidekiq::Job
|
2013-09-20 14:39:11 -07:00
|
|
|
#
|
|
|
|
# def perform
|
|
|
|
# $external_variable = 1
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# assert_equal 0, $external_variable
|
2022-03-03 12:37:25 -08:00
|
|
|
# ExternalJob.perform_async
|
2013-09-20 14:39:11 -07:00
|
|
|
# assert_equal 1, $external_variable
|
|
|
|
#
|
|
|
|
Sidekiq::Testing.inline!
|