diff --git a/lib/delayed_attachment_fu.rb b/lib/delayed_attachment_fu.rb index 5193245..87ffbf8 100644 --- a/lib/delayed_attachment_fu.rb +++ b/lib/delayed_attachment_fu.rb @@ -4,7 +4,7 @@ module DelayedAttachmentFu def delay_attachment_fu_thumbnails include DelayedAttachmentFu::InstanceMethods after_create do |file| - if file.image? + if file.thumbnailable? Delayed::Job.enqueue CreateThumbnailsJob.new(file.class.name, file.id) end end diff --git a/test/unit/image_test.rb b/test/unit/image_test.rb index b29a651..8357b30 100644 --- a/test/unit/image_test.rb +++ b/test/unit/image_test.rb @@ -84,4 +84,14 @@ class ImageTest < Test::Unit::TestCase end end + should 'not create a background job for an image that is already a thumbnail' do + # this test verifies whether it created background jobs also for the + # thumbnails! + assert_no_difference Delayed::Job, :count do + image = Image.new(:owner => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) + image.stubs(:is_thumbnail?).returns(true) + image.save! + end + end + end -- libgit2 0.21.2