Sha256: 7ba8d6086609ab0605a73345d2409db11cf7b24fbb261a700dca2201aee1acea

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'backgrounder/workers/store_asset'

describe CarrierWave::Workers::StoreAsset do
  let(:worker_class) { CarrierWave::Workers::StoreAsset }
  let(:user)   { mock('User') }
  let(:image)  { mock('UserAsset') }
  let!(:worker) { worker_class.new(user, '22', :image) }

  context ".perform" do
    it 'creates a new instance and calls perform' do
      args = [user, '22', :image]
      worker_class.expects(:new).with(*args).returns(worker)
      worker_class.any_instance.expects(:perform)

      worker_class.perform(*args)
    end
  end

  context "#perform" do
    it 'processes versions' do
      FileUtils.expects(:rm_r).with(File.expand_path('../fixtures/test.jpg', __FILE__),:force=>true).once
      user.expects(:find).with('22').once.returns(user)
      user.expects(:image_tmp).once.returns('test.jpg')
      user.expects(:image).once.returns(image)
      image.expects(:root).once.returns(File.expand_path('..', __FILE__))
      image.expects(:cache_dir).once.returns('fixtures')
      user.expects(:process_image_upload=).with(true).once
      user.expects(:image=).once
      user.expects(:image_tmp=).with(nil).once
      user.expects(:save!).once.returns(true)

      worker.perform
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
carrierwave_backgrounder-0.1.2 spec/backgrounder/workers/store_asset_spec.rb
carrierwave_backgrounder-0.1.1 spec/backgrounder/workers/store_asset_spec.rb
carrierwave_backgrounder-0.1.0 spec/backgrounder/workers/store_asset_spec.rb
carrierwave_backgrounder-0.0.9 spec/backgrounder/workers/store_asset_spec.rb
carrierwave_backgrounder-0.0.8 spec/backgrounder/workers/store_asset_spec.rb
carrierwave_backgrounder-0.0.7 spec/workers/store_asset_spec.rb
carrierwave_backgrounder-0.0.6 spec/workers/store_asset_spec.rb