FIX: crop & optimize user background profile/card images

This commit is contained in:
Régis Hanol
2015-07-15 17:15:43 +02:00
parent 00aaa692ac
commit b0802abae2
9 changed files with 70 additions and 64 deletions

View File

@ -45,7 +45,10 @@ describe Upload do
context "#create_for" do
before { Upload.stubs(:fix_image_orientation) }
before do
Upload.stubs(:fix_image_orientation)
ImageOptim.any_instance.stubs(:optimize_image!)
end
it "does not create another upload if it already exists" do
Upload.expects(:find_by).with(sha1: image_sha1).returns(upload)
@ -65,13 +68,6 @@ describe Upload do
Upload.create_for(user_id, image, image_filename, image_filesize)
end
it "does not create an upload when there is an error with FastImage" do
FileHelper.expects(:is_image?).returns(true)
Upload.expects(:save).never
upload = Upload.create_for(user_id, attachment, attachment_filename, attachment_filesize)
expect(upload.errors.size).to be > 0
end
it "does not compute width & height for non-image" do
FastImage.any_instance.expects(:size).never
upload = Upload.create_for(user_id, attachment, attachment_filename, attachment_filesize)