diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index f094bed..95d5251 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -102,4 +102,29 @@ class UploadedFileTest < Test::Unit::TestCase file.destroy end + should 'resize images bigger than in resize_to' do + fixture_filename = '/files/test-large-pic.jpg' + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename + system('echo "image for test" | convert -background yellow -page 1280x960 text:- %s' % filename) + + f = UploadedFile.create(:profile => @profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg')) + + assert_equal [640, 480], [f.width, f.height] + + File.rm_f(filename) + end + + should 'resize images on folder bigger than in resize_to' do + fixture_filename = '/files/test-large-pic.jpg' + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename + system('echo "image for test" | convert -background yellow -page 1280x960 text:- %s' % filename) + f = Folder.create!(:name => 'test_folder', :profile => @profile) + + file = UploadedFile.create(:profile => @profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg'), :parent_id => f.id) + + assert_equal [640, 480], [file.width, file.height] + + File.rm_f(filename) + end + end diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb index 3432684..ed7cd39 100644 --- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb +++ b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb @@ -419,7 +419,7 @@ module Technoweenie # :nodoc: # Resizes the given processed img object with either the attachment resize options or the thumbnail resize options. def resize_image_or_thumbnail!(img) - if (!respond_to?(:parent_id) || parent_id.nil?) && attachment_options[:resize_to] # parent image + if !is_thumbnail? && attachment_options[:resize_to] # parent image resize_image(img, attachment_options[:resize_to]) elsif thumbnail_resize_options # thumbnail resize_image(img, thumbnail_resize_options) -- libgit2 0.21.2