Commit 71b58fa6 authored by Maxwell Salzberg's avatar Maxwell Salzberg

only queue process_photo jobs if the owner is local. this should cut down on some resque errors

parent 8b4cb744
......@@ -25,7 +25,9 @@ class Photo < ActiveRecord::Base
before_destroy :ensure_user_picture
after_destroy :clear_empty_status_message
after_create :queue_processing_job
after_create do
queue_processing_job if self.author.local?
end
after_save do
self.status_message.update_photos_counter if status_message
......
......@@ -106,6 +106,14 @@ Factory.define(:photo) do |p|
end
end
Factory.define(:remote_photo, :parent => :photo) do |p|
p.remote_photo_path 'https://photo.com/images/'
p.remote_photo_name 'kittehs.jpg'
p.association :author,:factory => :person
p.processed_image nil
p.unprocessed_image nil
end
Factory.define :reshare do |r|
r.association(:root, :public => true, :factory => :status_message)
r.association(:author, :factory => :person)
......
......@@ -54,4 +54,13 @@ describe Jobs::ProcessPhoto do
result.should be false
end
end
it 'does not throw an error if it is called on a remote photo' do
p = Factory(:remote_photo)
p.unprocessed_image = nil
expect{
result = Jobs::ProcessPhoto.perform(p.id)
}.to_not raise_error
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment