forked from e621ng/e621ng
fixes #1905
This commit is contained in:
parent
e3227d1e3d
commit
b945c757c8
2
Gemfile
2
Gemfile
@ -40,7 +40,7 @@ gem 'bcrypt-ruby', :require => "bcrypt"
|
||||
gem 'aws-s3', :require => "aws/s3"
|
||||
gem 'awesome_print'
|
||||
gem 'statistics2'
|
||||
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git"
|
||||
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes"
|
||||
|
||||
group :production do
|
||||
gem 'unicorn', :platforms => :ruby
|
||||
|
@ -25,7 +25,8 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: https://github.com/r888888888/ruby-imagespec.git
|
||||
revision: 41859ac5808cd64f2385082171ee2cc9f80bfcd1
|
||||
revision: 2dab9811f4abb4fbaeea66feb42e388ba545b2d8
|
||||
branch: exif-fixes
|
||||
specs:
|
||||
ruby-imagespec (0.3.1)
|
||||
|
||||
|
@ -22,6 +22,22 @@ FactoryGirl.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory(:exif_jpg_upload) do
|
||||
content_type "image/jpeg"
|
||||
file_path do
|
||||
FileUtils.cp("#{Rails.root}/test/files/test-exif-small.jpg", "#{Rails.root}/tmp")
|
||||
"#{Rails.root}/tmp/test-exif-small.jpg"
|
||||
end
|
||||
end
|
||||
|
||||
factory(:blank_jpg_upload) do
|
||||
content_type "image/jpeg"
|
||||
file_path do
|
||||
FileUtils.cp("#{Rails.root}/test/files/test-blank.jpg", "#{Rails.root}/tmp")
|
||||
"#{Rails.root}/tmp/test-blank.jpg"
|
||||
end
|
||||
end
|
||||
|
||||
factory(:large_jpg_upload) do
|
||||
file_ext "jpg"
|
||||
content_type "image/jpeg"
|
||||
|
BIN
test/files/test-blank.jpg
Normal file
BIN
test/files/test-blank.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
test/files/test-exif-small.jpg
Normal file
BIN
test/files/test-exif-small.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
@ -69,13 +69,27 @@ class UploadTest < ActiveSupport::TestCase
|
||||
assert_equal(756, @upload.image_height)
|
||||
end
|
||||
|
||||
should "discover the dimensions for a JPG" do
|
||||
should "discover the dimensions for a JPG with JFIF data" do
|
||||
@upload = FactoryGirl.create(:jpg_upload)
|
||||
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
|
||||
assert_equal(500, @upload.image_width)
|
||||
assert_equal(335, @upload.image_height)
|
||||
end
|
||||
|
||||
should "discover the dimensions for a JPG with EXIF data" do
|
||||
@upload = FactoryGirl.create(:exif_jpg_upload)
|
||||
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
|
||||
assert_equal(529, @upload.image_width)
|
||||
assert_equal(600, @upload.image_height)
|
||||
end
|
||||
|
||||
should "discover the dimensions for a JPG with no header data" do
|
||||
@upload = FactoryGirl.create(:blank_jpg_upload)
|
||||
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
|
||||
assert_equal(668, @upload.image_width)
|
||||
assert_equal(996, @upload.image_height)
|
||||
end
|
||||
|
||||
should "discover the dimensions for a PNG" do
|
||||
@upload = FactoryGirl.create(:png_upload)
|
||||
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
|
||||
|
Loading…
Reference in New Issue
Block a user