test both local and remote attachment cases

pull/9839/head
Markus Kahl 3 years ago
parent dafa2a3aac
commit d19d2623c0
  1. 26
      spec/models/attachment_spec.rb

@ -244,12 +244,27 @@ describe Attachment, type: :model do
end
end
shared_examples "it uses content disposition inline" do
let(:attachment) { raise "define me!" }
describe 'the external url (for remote attachments)' do
it 'contains inline content disposition without the filename' do
expect(attachment.external_url.to_s).to include "response-content-disposition=inline&"
end
end
describe 'content disposition (for local attachments)' do
it 'is inline, including the filename' do
expect(attachment.content_disposition).to eq "inline; filename=#{attachment.filename}"
end
end
end
describe "for an image file" do
before { image_attachment.save! }
it "should make S3 use content_disposition inline" do
expect(image_attachment.content_disposition).to eq "inline; filename=image.png"
expect(image_attachment.external_url.to_s).to include "response-content-disposition=inline"
it_behaves_like "it uses content disposition inline" do
let(:attachment) { image_attachment }
end
# this is independent from the type of file uploaded so we just test this for the first one
@ -261,9 +276,8 @@ describe Attachment, type: :model do
describe "for a text file" do
before { text_attachment.save! }
it "should make S3 use content_disposition inline" do
expect(text_attachment.content_disposition).to eq "inline; filename=testfile.txt"
expect(text_attachment.external_url.to_s).to include "response-content-disposition=inline"
it_behaves_like "it uses content disposition inline" do
let(:attachment) { text_attachment }
end
end

Loading…
Cancel
Save