This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Don't write original if it wasn't reprocessed #1993
Closed
sashazykov
wants to merge
6
commits into
thoughtbot:master
from
sashazykov:don-write-original-if-not-needed
+55
−0
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bb4e224
don't write original if it's not needed
sashazykov 92dc2f8
refactored
sashazykov 4030cba
added test for #1993
sashazykov 0572bb7
fixed some of hound comments
sashazykov acbf258
fixed some of hound comments
sashazykov d9bcc8d
style fixes
sashazykov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,6 +379,58 @@ def counter | |
end | ||
end | ||
|
||
context "An attachment that uses S3 for storage and has styles" do | ||
before do | ||
rebuild_model( | ||
(aws2_add_region).merge( | ||
storage: :s3, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis. |
||
styles: { thumb: ["90x90#", :jpg] }, | ||
bucket: "bucket", | ||
s3_credentials: { | ||
"access_key_id" => "12345", | ||
"secret_access_key" => "54321" } | ||
) | ||
) | ||
|
||
@file = File.new(fixture_file("5k.png"), "rb") | ||
@dummy = Dummy.new | ||
@dummy.avatar = @file | ||
@dummy.save | ||
end | ||
|
||
context "reprocess" do | ||
before do | ||
@object = stub | ||
@dummy.avatar.stubs(:s3_object).with(:original).returns(@object) | ||
@dummy.avatar.stubs(:s3_object).with(:thumb).returns(@object) | ||
@object.stubs(defined?(::Aws) ? :get : :read).yields(@file.read) | ||
@object.stubs(:exists?).returns(true) | ||
end | ||
|
||
it "uploads original" do | ||
@object.expects((defined?(::Aws) ? :upload_file : :write)).with( | ||
anything, | ||
content_type: "image/png", | ||
acl: Paperclip::Storage::S3::DEFAULT_PERMISSION).returns(true) | ||
@object.expects((defined?(::Aws) ? :upload_file : :write)).with( | ||
anything, | ||
content_type: "image/jpeg", | ||
acl: Paperclip::Storage::S3::DEFAULT_PERMISSION).returns(true) | ||
@dummy.avatar.reprocess! | ||
end | ||
|
||
it "doesn't upload original" do | ||
@object.expects((defined?(::Aws) ? :upload_file : :write)).with( | ||
anything, | ||
content_type: "image/jpeg", | ||
acl: Paperclip::Storage::S3::DEFAULT_PERMISSION).returns(true) | ||
@dummy.avatar.reprocess!(:thumb) | ||
end | ||
end | ||
|
||
after { @file.close } | ||
end | ||
|
||
context "An attachment that uses S3 for storage and has spaces in file name" do | ||
before do | ||
rebuild_model( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [85/80]