* Dropped all references to Resque * Moved all jobs under app/workers since that's the Sidekiq convention * Renamed Jobs module to Worker to match new location * Adapted all jobs to Sidekiq * Replaced all enqueue calls with perform_async * Dropped Resque hacks from specs and features, replaced with sidekig/testing in RSpec and sidekig/testing/inline in Cucumber * Updated scripts to start a Sidekiq server * Inline Sidekiq sinatra app * Let Sidekiq create the actual Redis instance * Workaround already initialized constant warnings in service models * Resolved ToDo in one job definition by creating proper exception clases for some errors in receiving posts * Added sidekiq section to configuration to make it completly configurable to the user * Add Sidekiq middleware for clean backtraces * Delay HttpMulti retry to give offline pods a chance to come back up * Do not retry on GUID already taken and alike errors * Be graceful about deleted posts in GatherOEmbedData
66 lines
1.8 KiB
Ruby
66 lines
1.8 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Workers::ProcessPhoto do
|
|
before do
|
|
@user = alice
|
|
@aspect = @user.aspects.first
|
|
|
|
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', 'button.png')
|
|
|
|
@saved_photo = @user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
|
|
@saved_photo.save
|
|
end
|
|
|
|
it 'saves the processed image' do
|
|
@saved_photo.processed_image.path.should be_nil
|
|
|
|
result = Workers::ProcessPhoto.new.perform(@saved_photo.id)
|
|
|
|
@saved_photo.reload
|
|
|
|
@saved_photo.processed_image.path.should_not be_nil
|
|
result.should be true
|
|
end
|
|
|
|
context 'when trying to process a photo that has already been processed' do
|
|
before do
|
|
Workers::ProcessPhoto.new.perform(@saved_photo.id)
|
|
@saved_photo.reload
|
|
end
|
|
|
|
it 'does not process the photo' do
|
|
processed_image_path = @saved_photo.processed_image.path
|
|
|
|
result = Workers::ProcessPhoto.new.perform(@saved_photo.id)
|
|
|
|
@saved_photo.reload
|
|
|
|
@saved_photo.processed_image.path.should == processed_image_path
|
|
result.should be false
|
|
end
|
|
end
|
|
|
|
context 'when a gif is uploaded' do
|
|
before do
|
|
@fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', 'button.gif')
|
|
@saved_gif = @user.build_post(:photo, :user_file => File.open(@fixture_name), :to => @aspect.id)
|
|
@saved_gif.save
|
|
end
|
|
|
|
it 'does not process the gif' do
|
|
result = Workers::ProcessPhoto.new.perform(@saved_gif.id)
|
|
|
|
@saved_gif.reload.processed_image.path.should be_nil
|
|
result.should be false
|
|
end
|
|
end
|
|
|
|
it 'does not throw an error if it is called on a remote photo' do
|
|
p = FactoryGirl.create(:remote_photo)
|
|
p.unprocessed_image = nil
|
|
expect{
|
|
result = Workers::ProcessPhoto.new.perform(p.id)
|
|
}.to_not raise_error
|
|
|
|
end
|
|
end
|