Apply suggestions from code review.

Co-authored-by: Mitsuhiro Shibuya <mit.shibuya@gmail.com>
This commit is contained in:
Simon Schrape 2022-07-20 08:25:53 +02:00 committed by GitHub
parent cdc14f8106
commit 807e743e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -487,7 +487,7 @@ module CarrierWave
def copy_options
options = {}
options.merge!(acl_header) if acl_header.present?
options['Content-Type'] = options[:content_type] ||= content_type if content_type
options[fog_provider == "Google" ? :content_type : 'Content-Type'] ||= content_type if content_type
options.merge(@uploader.fog_attributes)
end

View File

@ -606,15 +606,14 @@ end
if @provider == 'AWS'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type, "x-amz-acl"=>"public-read", 'x-amz-server-side-encryption' => 'AES256' }).and_call_original
{ "Content-Type"=>@fog_file.content_type, "x-amz-acl"=>"public-read", 'x-amz-server-side-encryption' => 'AES256' }).and_call_original
elsif @provider == 'Google'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type, destination_predefined_acl: "publicRead" }).and_call_original
{ content_type: @fog_file.content_type, destination_predefined_acl: "publicRead" }).and_call_original
else
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type }).and_call_original
.with(anything, anything, anything, anything, { "Content-Type"=>@fog_file.content_type }).and_call_original
end
@fog_file.copy_to('uploads/new_path.jpg')
@ -625,16 +624,14 @@ end
it 'includes acl_header when necessary' do
if @provider == 'AWS'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type, "x-amz-acl"=>"public-read" }).and_call_original
.with(anything, anything, anything, anything, { "Content-Type"=>@fog_file.content_type, "x-amz-acl"=>"public-read" }).and_call_original
elsif @provider == 'Google'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type, destination_predefined_acl: "publicRead" }).and_call_original
{ content_type: @fog_file.content_type, destination_predefined_acl: "publicRead" }).and_call_original
else
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>@fog_file.content_type, content_type: @fog_file.content_type }).and_call_original
.with(anything, anything, anything, anything, { "Content-Type"=>@fog_file.content_type }).and_call_original
end
@fog_file.copy_to('uploads/new_path.jpg')