Sha256: ce9611382806b4c47872636b9dd27aa96e08bf13cc4467c54e3939092db33733

Contents?: true

Size: 1.97 KB

Versions: 5

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'
require 'resque'

describe DelayedPaperclip do
  before :all do
    reset_dummy
  end

  describe ".options" do
    it ".options returns basic options" do
      DelayedPaperclip.options.should == {:background_job_class => DelayedPaperclip::Jobs::Resque,
                                          :url_with_processing => true,
                                          :processing_image_url => nil}
    end
  end

  describe ".processor" do
    it ".processor returns processor" do
      DelayedPaperclip.processor.should == DelayedPaperclip::Jobs::Resque
    end
  end

  describe ".enqueue" do
    it "delegates to processor" do
      DelayedPaperclip::Jobs::Resque.expects(:enqueue_delayed_paperclip).with("Dummy", 1, :image)
      DelayedPaperclip.enqueue("Dummy", 1, :image)
    end
  end

  describe ".process_job" do
    let(:dummy) { Dummy.create! }

    it "finds dummy and calls #process_delayed!" do
      dummy_stub = stub
      dummy_stub.expects(:find).with(dummy.id).returns(dummy)
      Dummy.expects(:unscoped).returns(dummy_stub)
      dummy.image.expects(:process_delayed!)
      DelayedPaperclip.process_job("Dummy", dummy.id, :image)
    end
  end

  describe "paperclip definitions" do
    before :all do
      reset_dummy :paperclip => { styles: { thumbnail: "25x25"} }
    end

    it "returns paperclip options regardless of version" do
      Dummy.paperclip_definitions.should ==  {:image =>   { :styles => { :thumbnail => "25x25" },
                                              :delayed => { :priority => 0,
                                                            :only_process => [],
                                                            :url_with_processing => true,
                                                            :processing_image_url => nil,
                                                            :queue => nil}
                                                          }
                                              }
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
delayed_paperclip-2.9.1 spec/delayed_paperclip_spec.rb
delayed_paperclip-2.9.0 spec/delayed_paperclip_spec.rb
delayed_paperclip-2.8.0 spec/delayed_paperclip_spec.rb
delayed_paperclip-2.7.1 spec/delayed_paperclip_spec.rb
delayed_paperclip-2.7.0 spec/delayed_paperclip_spec.rb