Skip to content
Extraits de code Groupes Projets
Valider 71b58fa6 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

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

parent 8b4cb744
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -25,7 +25,9 @@ class Photo < ActiveRecord::Base ...@@ -25,7 +25,9 @@ class Photo < ActiveRecord::Base
before_destroy :ensure_user_picture before_destroy :ensure_user_picture
after_destroy :clear_empty_status_message 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 after_save do
self.status_message.update_photos_counter if status_message self.status_message.update_photos_counter if status_message
......
...@@ -106,6 +106,14 @@ Factory.define(:photo) do |p| ...@@ -106,6 +106,14 @@ Factory.define(:photo) do |p|
end end
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| Factory.define :reshare do |r|
r.association(:root, :public => true, :factory => :status_message) r.association(:root, :public => true, :factory => :status_message)
r.association(:author, :factory => :person) r.association(:author, :factory => :person)
......
...@@ -54,4 +54,13 @@ describe Jobs::ProcessPhoto do ...@@ -54,4 +54,13 @@ describe Jobs::ProcessPhoto do
result.should be false result.should be false
end end
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 end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter