diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b1d7ae1942c3..f1eb8ad9cae3 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -163,8 +163,12 @@ def is_pdf? content_type == "application/pdf" end + def is_html? + content_type == "text/html" + end + def is_text? - content_type.match?(/\Atext\/.+/) + content_type.match?(/\Atext\/.+/) && !is_html? end def is_diff? diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index cb061fcbab00..91b249efa187 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -295,6 +295,17 @@ end end + describe "for an HTML file" do + let(:attachment) { described_class.new } + + it "assumes it not to be inlineable" do + attachment.content_type = "text/html" + expect(attachment).to be_is_html + expect(attachment).not_to be_is_text + expect(attachment).not_to be_inlineable + end + end + describe "for a binary file" do before { binary_attachment.save! }