2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-20 14:33:35 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Gitlab::Email::AttachmentUploader do
|
2015-08-20 14:33:35 -04:00
|
|
|
describe "#execute" do
|
2017-12-01 08:58:49 -05:00
|
|
|
let(:project) { create(:project) }
|
2015-08-20 14:33:35 -04:00
|
|
|
let(:message_raw) { fixture_file("emails/attachment.eml") }
|
|
|
|
let(:message) { Mail::Message.new(message_raw) }
|
|
|
|
|
2015-08-20 15:41:47 -04:00
|
|
|
it "uploads all attachments and returns their links" do
|
2020-01-14 04:08:19 -05:00
|
|
|
links = described_class.new(message).execute(upload_parent: project, uploader_class: FileUploader)
|
2015-08-20 14:33:35 -04:00
|
|
|
link = links.first
|
|
|
|
|
|
|
|
expect(link).not_to be_nil
|
|
|
|
expect(link[:alt]).to eq("bricks")
|
|
|
|
expect(link[:url]).to include("bricks.png")
|
|
|
|
end
|
2020-02-18 07:09:15 -05:00
|
|
|
|
|
|
|
context 'with a signed message' do
|
|
|
|
let(:message_raw) { fixture_file("emails/valid_reply_signed_smime.eml") }
|
|
|
|
|
|
|
|
it 'uploads all attachments except the signature' do
|
|
|
|
links = described_class.new(message).execute(upload_parent: project, uploader_class: FileUploader)
|
|
|
|
|
|
|
|
expect(links).not_to include(a_hash_including(alt: 'smime.p7s'))
|
|
|
|
|
|
|
|
image_link = links.first
|
|
|
|
expect(image_link).not_to be_nil
|
|
|
|
expect(image_link[:alt]).to eq('gitlab_logo')
|
|
|
|
expect(image_link[:url]).to include('gitlab_logo.png')
|
|
|
|
end
|
|
|
|
end
|
2015-08-20 14:33:35 -04:00
|
|
|
end
|
|
|
|
end
|