Sha256: 0144bee8be09f25d40f631a0a03457015a32e43a757580fe6bb0ecdbed9be55b

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require File.join(File.dirname(__FILE__) + '/../spec_helper')

describe Resque::Job do
  it "should repush restriction queue when reserve" do
    Resque.redis.flushall
    Resque.push('restriction', :class => 'OneHourRestrictionJob', :args => ['any args'])
    Resque::Job.reserve('restriction').should be_nil
    Resque::Job.reserve('normal').should == Resque::Job.new('normal', {'class' => 'OneHourRestrictionJob', 'args' => ['any args']})
    Resque::Job.reserve('normal').should be_nil
  end

  it "should push back to restriction queue when still restricted" do
    Resque.redis.flushall
    Resque.redis.set(OneHourRestrictionJob.redis_key(:per_hour), -1)
    Resque.push('restriction', :class => 'OneHourRestrictionJob', :args => ['any args'])
    Resque::Job.reserve('restriction').should be_nil
    Resque.pop('restriction').should == {'class' => 'OneHourRestrictionJob', 'args' => ['any args']}
    Resque::Job.reserve('normal').should be_nil
  end

  it "should not repush when reserve normal queue" do
    Resque.push('normal', :class => 'OneHourRestrictionJob', :args => ['any args'])
    Resque::Job.reserve('normal').should == Resque::Job.new('normal', {'class' => 'OneHourRestrictionJob', 'args' => ['any args']})
    Resque::Job.reserve('normal').should be_nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resque-restriction-0.2.1 spec/resque-restriction/job_spec.rb
resque-restriction-0.2.0 spec/resque-restriction/job_spec.rb