test/processor_test.rb in attachs-0.4.4 vs test/processor_test.rb in attachs-0.4.5

- old
+ new

@@ -1,43 +1,46 @@ require 'test_helper' class ProcessorTest < ActiveSupport::TestCase + setup do + FileUtils.mkdir_p resized_path.dirname + FileUtils.cp source_path, resized_path + end + teardown do - Dir[Rails.root.join('tmp', '*')].each do |file| - File.delete file - end + clean_storage end test 'force resize' do - Attachs::Processors::Thumbnail.new(nil, source).process(:big_force, resized) - assert_equal [160,130], dimensions(resized) - Attachs::Processors::Thumbnail.new(nil, source).process(:small_force, resized) - assert_equal [140,110], dimensions(resized) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:big_force, resized_path) + assert_equal [160,130], dimensions(resized_path) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:small_force, resized_path) + assert_equal [140,110], dimensions(resized_path) end test 'cover resize' do - Attachs::Processors::Thumbnail.new(nil, source).process(:big_cover, resized) - assert_equal [160,130], dimensions(resized) - Attachs::Processors::Thumbnail.new(nil, source).process(:small_cover, resized) - assert_equal [140,110], dimensions(resized) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:big_cover, resized_path) + assert_equal [160,130], dimensions(resized_path) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:small_cover, resized_path) + assert_equal [140,110], dimensions(resized_path) end test 'contain resize' do - Attachs::Processors::Thumbnail.new(nil, source).process(:big_contain, resized) - assert_equal [156,130], dimensions(resized) - Attachs::Processors::Thumbnail.new(nil, source).process(:small_contain, resized) - assert_equal [132,110], dimensions(resized) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:big_contain, resized_path) + assert_equal [156,130], dimensions(resized_path) + Attachs::Processors::Thumbnail.new(nil, source_path).process(:small_contain, resized_path) + assert_equal [132,110], dimensions(resized_path) end private - def source + def source_path image_upload.path end - def resized - Rails.root.join('public', 'resized.gif') + def resized_path + Rails.root.join('public/storage/processor/resized.gif') end def dimensions(source) `identify -format %wx%h '#{source}'`.split('x').map(&:to_i) end