only queue process_photo jobs if the owner is local. this should cut down on some resque errors
This commit is contained in:
parent
8b4cb744e6
commit
71b58fa6fc
3 changed files with 20 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue