This commit is contained in:
Toks
2013-08-06 15:12:40 -04:00
9 changed files with 43 additions and 6 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -3,7 +3,9 @@ require 'test_helper'
class PostFlagsControllerTest < ActionController::TestCase
context "The post flags controller" do
setup do
@user = FactoryGirl.create(:user)
Timecop.travel(2.weeks.ago) do
@user = FactoryGirl.create(:user)
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end

View File

@@ -7,7 +7,9 @@ class PostPrunerTest < ActiveSupport::TestCase
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@flagger = FactoryGirl.create(:user)
Timecop.travel(2.weeks.ago) do
@flagger = FactoryGirl.create(:gold_user)
end
@old_post = FactoryGirl.create(:post, :created_at => 5.days.ago, :is_pending => true)
@unresolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true)
@resolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true)

View File

@@ -2,7 +2,9 @@ require 'test_helper'
class PostTest < ActiveSupport::TestCase
setup do
@user = FactoryGirl.create(:user)
Timecop.travel(2.weeks.ago) do
@user = FactoryGirl.create(:user)
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all

View File

@@ -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)}