Sha256: 91ece57b769c69206ff624aa87432caef3da7298c82fb086f3e12d504538c2b1

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

require 'active_job'

# Allows us to test that we can find working jobs
class OngoingJob
  def self.queue
    :quick
  end

  def self.perform
    sleep 5
  end
end

# Generic job to use as a base class for the test jobs below.
class SomeJob
  def self.perform(_repo_id, _path)
  end
end

# Test job
class SomeQuickJob < SomeJob
  @queue = :quick
end

# Test job
class SomeIvarJob < SomeJob
  @queue = :ivar
end

# Job for tests where we put it into more than one environment and test that it
# only shows up for one.
class SomeSharedEnvJob < SomeJob
  def self.queue
    :shared_job
  end
end

# Job for tests, where we expect there to be parameters provided.
class JobWithParams
  @queue = :quick

  def self.perform(*args)
    @args = args
  end
end

JobWithoutParams = Class.new(JobWithParams) do
  @queue = :quick
end

# Allows us to test whether jobs added via the ActiveJob wrapper are correctly
# handled.
class ActiveJobTest < ActiveJob::Base
  queue_as :test_queue

  def self.queue
    queue_name
  end

  def perform
  end
end

# Test module
module Foo
  # Test class
  class Bar
    def self.queue
      'bar'
    end
  end
end

# This is just a container for a dummy schedule.
module Test
  RESQUE_SCHEDULE = {
    'job_without_params' => {
      'cron' => '* * * * *',
      'class' => 'JobWithoutParams',
      'args' => {
        'host' => 'localhost'
      },
      'rails_env' => 'production'
    },
    'job_with_params' => {
      'every' => '1m',
      'class' => 'JobWithParams',
      'args' => {
        'host' => 'localhost'
      },
      'parameters' => {
        'log_level' => {
          'description' => 'The level of logging',
          'default' => 'warn'
        }
      }
    }
  }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque-scheduler-web-1.1.0 spec/support/test_jobs.rb
resque-scheduler-web-1.0.1 spec/support/test_jobs.rb
resque-scheduler-web-1.0.0 spec/support/test_jobs.rb