Sha256: 4e4749af4d80cfe684ff73a7b37045e1a02311f40b033991f6c83b0423197eee

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'sidekiq/api'

describe "Sidekiq" do

  before :all do
    Sidekiq.logger.level = Logger::ERROR
    DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Sidekiq
    Sidekiq::Queue.new(:paperclip).clear
  end

  let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) }

  describe "integration tests" do
    include_examples "base usage"
  end

  describe "perform job" do
    before :each do
      DelayedPaperclip.options[:url_with_processing] = true
      reset_dummy
    end

    it "performs a job" do
      dummy.image = File.open("#{ROOT}/spec/fixtures/12k.png")
      Paperclip::Attachment.any_instance.expects(:reprocess!)
      dummy.save!
      DelayedPaperclip::Jobs::Sidekiq.new.perform(dummy.class.name, dummy.id, :image)
    end
  end

  def process_jobs
    Sidekiq::Queue.new(:paperclip).each do |job|
      worker = job.klass.constantize.new
      args   = job.args
      begin
        worker.perform(*args)
      rescue # Assume sidekiq handle exception properly
      end
      job.delete
    end
  end

  def jobs_count
    Sidekiq::Queue.new(:paperclip).size
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
delayed_paperclip-2.9.1 spec/integration/sidekiq_spec.rb
delayed_paperclip-2.9.0 spec/integration/sidekiq_spec.rb
delayed_paperclip-2.8.0 spec/integration/sidekiq_spec.rb