2012-02-10 00:46:44 -05:00
|
|
|
module Sidekiq
|
|
|
|
module Worker
|
2012-02-10 23:30:14 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# The Sidekiq testing infrastructure just overrides perform_async
|
|
|
|
# so that it does not actually touch the network. Instead it
|
|
|
|
# just stores the asynchronous jobs in a per-class array so that
|
|
|
|
# their presence/absence can be asserted by your tests.
|
|
|
|
#
|
|
|
|
# This is similar to ActionMailer's :test delivery_method and its
|
|
|
|
# ActionMailer::Base.deliveries array.
|
2012-02-10 00:46:44 -05:00
|
|
|
module ClassMethods
|
2012-02-10 01:33:36 -05:00
|
|
|
alias_method :perform_async_old, :perform_async
|
2012-02-10 00:46:44 -05:00
|
|
|
def perform_async(*args)
|
2012-02-10 23:30:14 -05:00
|
|
|
jobs << args
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def jobs
|
|
|
|
@pushed ||= []
|
2012-02-10 00:46:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|