Sha256: 9f0c736b74c6f6f43d920cd8df178af786d6eaccf91dc9429da03ea0a8ac141b

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

Contents

require 'spec_helper'

module DestroySoon
  describe Queue do
    after do
      Delayed::Job.destroy_all
    end
    before(:all) do
      class User < ActiveRecord::Base
        include DestroySoon::ModelAdditions
      end
    end
    let(:user) do
      User.create(:name => "call me susy")
    end
    let(:job) do
      Job.new(:entity => user)
    end
    let(:subject) do
      Queue.new
    end

    it "should enqueue the job" do
      Delayed::Job.should_receive(:enqueue).with(job)
      subject.enqueue(job)
    end

    it "should enqueue the job on the configured queue" do
      Queue.default_queue = "general"
      Delayed::Job.should_receive(:enqueue).with(job, :queue => "general")
      subject.enqueue(job)
      Queue.default_queue = nil
    end

    it "should call destroy after all" do
      User.any_instance.should_receive(:destroy).once
      subject.enqueue(job)
    end

    it "should return the job" do
      subject.enqueue(job).should be_a Delayed::Job
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
destroy_soon-0.0.3 spec/queue_spec.rb
destroy_soon-0.0.2 spec/queue_spec.rb
destroy_soon-0.0.1 spec/queue_spec.rb