Skip to content

Commit

Permalink
Add specs for MS Office mime type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonypenner committed Feb 17, 2020
1 parent 6baa070 commit 37af967
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Binary file added spec/fixtures/resume.docx
Binary file not shown.
Binary file added spec/fixtures/slidedeck.pptx
Binary file not shown.
20 changes: 20 additions & 0 deletions spec/sanitized_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@
expect(sanitized_file.content_type).to eq("application/msword")
end

it "handles Mime::Type of docx" do
file = File.open(file_path('resume.docx'))

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

expect { sanitized_file.content_type }.not_to raise_error
expect(sanitized_file.content_type).to eq("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
end

it "handles Mime::Type of pptx" do
file = File.open(file_path('slidedeck.pptx'))

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

expect { sanitized_file.content_type }.not_to raise_error
expect(sanitized_file.content_type).to eq("application/vnd.openxmlformats-officedocument.presentationml.presentation")
end

it "reads content type from path if missing" do
sanitized_file = CarrierWave::SanitizedFile.new("llama.jpg")

Expand Down

0 comments on commit 37af967

Please sign in to comment.