mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: crop & optimize user background profile/card images
This commit is contained in:
@@ -303,8 +303,11 @@ This is a link http://example.com"
|
||||
let(:upload_sha) { '04df605be528d03876685c52166d4b063aabb78a' }
|
||||
|
||||
it "creates a post with an attachment" do
|
||||
Upload.stubs(:fix_image_orientation)
|
||||
ImageOptim.any_instance.stubs(:optimize_image!)
|
||||
|
||||
start_count = topic.posts.count
|
||||
Upload.find_by(sha1: upload_sha).try :destroy
|
||||
Upload.find_by(sha1: upload_sha).try(:destroy)
|
||||
|
||||
receiver.process
|
||||
|
||||
|
||||
BIN
spec/fixtures/images/logo-dev.png
vendored
BIN
spec/fixtures/images/logo-dev.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 3.1 KiB |
BIN
spec/fixtures/images/logo.png
vendored
BIN
spec/fixtures/images/logo.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user