From aefc577817f089057e6ec292c7bb2589be0f7ed6 Mon Sep 17 00:00:00 2001 From: Long Date: Sun, 24 Mar 2019 13:38:16 +0700 Subject: [PATCH] Do not return unexpected false for content type when file is deleted --- lib/carrierwave/storage/fog.rb | 2 +- spec/storage/fog_helper.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/carrierwave/storage/fog.rb b/lib/carrierwave/storage/fog.rb index 5ec5c5266..7c11fc160 100644 --- a/lib/carrierwave/storage/fog.rb +++ b/lib/carrierwave/storage/fog.rb @@ -218,7 +218,7 @@ def authenticated_url(options = {}) # [String] value of content-type # def content_type - @content_type || !file.nil? && file.content_type + @content_type || file&.content_type end ## diff --git a/spec/storage/fog_helper.rb b/spec/storage/fog_helper.rb index 455698a6b..78497259d 100644 --- a/spec/storage/fog_helper.rb +++ b/spec/storage/fog_helper.rb @@ -251,8 +251,8 @@ class FogSpec#{fog_credentials[:provider]}Uploader < CarrierWave::Uploader::Base expect { @fog_file.size }.not_to raise_error end - it "should not error getting the content type" do - expect { @fog_file.content_type }.not_to raise_error + it "should return a string or nil for content type" do + expect { @fog_file.content_type&.size }.not_to raise_error end end end