From 0195c8c15c55316439c837032a572efeb137961e Mon Sep 17 00:00:00 2001 From: "M.Shibuya" Date: Tue, 30 Apr 2019 19:13:34 +0900 Subject: [PATCH] Make #2384 work with Ruby 2.2 --- lib/carrierwave/storage/fog.rb | 2 +- spec/storage/fog_helper.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/carrierwave/storage/fog.rb b/lib/carrierwave/storage/fog.rb index 2d694dd94..5a8eb0eb4 100644 --- a/lib/carrierwave/storage/fog.rb +++ b/lib/carrierwave/storage/fog.rb @@ -216,7 +216,7 @@ def authenticated_url(options = {}) # [String] value of content-type # def content_type - @content_type || file&.content_type + @content_type || file.try(:content_type) end ## diff --git a/spec/storage/fog_helper.rb b/spec/storage/fog_helper.rb index 78497259d..63a8e8110 100644 --- a/spec/storage/fog_helper.rb +++ b/spec/storage/fog_helper.rb @@ -251,8 +251,12 @@ class FogSpec#{fog_credentials[:provider]}Uploader < CarrierWave::Uploader::Base expect { @fog_file.size }.not_to raise_error end - it "should return a string or nil for content type" do - expect { @fog_file.content_type&.size }.not_to raise_error + it "should not error getting the content type" do + expect { @fog_file.content_type }.not_to raise_error + end + + it "should return false for content type" do + expect(@fog_file.content_type).not_to be false end end end