Skip to content

Commit

Permalink
Simplify the implementation by removing a stub
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleypriest committed May 12, 2018
1 parent 21771e6 commit 7b90f2c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions lib/carrierwave/sanitized_file.rb
Expand Up @@ -261,11 +261,7 @@ def to_file
def content_type
return @content_type if @content_type
if @file.respond_to?(:content_type) and @file.content_type
if @file.content_type.respond_to?(:content_type)
@content_type = @file.content_type.content_type.chomp
else
@content_type = @file.content_type.to_s.chomp
end
@content_type = @file.content_type.to_s.chomp
elsif path
mime_type = ::MiniMime.lookup_by_filename(path)
@content_type = (mime_type && mime_type.content_type).to_s
Expand Down
3 changes: 1 addition & 2 deletions spec/sanitized_file_spec.rb
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'mini_mime'

describe CarrierWave::SanitizedFile do
before do
Expand Down Expand Up @@ -183,7 +182,7 @@

it "handles Mime::Type object" do
file = File.open(file_path('sponsored.doc'))
allow(file).to receive(:content_type).and_return(MiniMime.lookup_by_content_type("application/msword"))

sanitized_file = CarrierWave::SanitizedFile.new(file)
allow(sanitized_file).to receive(:file).and_return(file)

Expand Down

0 comments on commit 7b90f2c

Please sign in to comment.