Skip to content

Commit

Permalink
Remove disabled email attachment specs
Browse files Browse the repository at this point in the history
These were disabled a year ago in commit d57130d, which adds other
tests for the behaviour of attachments. These specs are no longer needed
nor useful.
  • Loading branch information
threedaymonk committed Dec 3, 2024
1 parent 017360d commit 61f3418
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions spec/integration/outlook_email_delivery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,51 +141,4 @@
end
end
end

xdescribe "attached files" do
def as_adu(ffu)
ActionDispatch::Http::UploadedFile.new(tempfile: ffu.tempfile, filename: ffu.original_filename, type: ffu.content_type)
end

describe "uploaded by the user" do
let(:file_attachments) { [as_adu(fixture_file_upload(Rails.root.join("spec/fixtures/support/text-file.txt"), "text/plain"))] }

it "appear in the list of attachments" do
expect(draft_email.attachments.count).to eq(1)
expect(draft_email.attachments.first.content_type).to eq("text/plain")
expect(draft_email.attachments.first.name).to eq("text-file.txt")
expect(draft_email.attachments.first.content_bytes).to eq(Base64.encode64(file_attachments.first.tap(&:rewind).read))
end

context "when the file is infected" do
before { allow(Support::VirusScanner).to receive(:uploaded_file_safe?).and_return(false) }

it "makes the email invalid" do
expect(draft_email).not_to be_valid
expect(draft_email.errors[:file_attachments]).to include("One or more of the files you uploaded contained a virus")
end
end

context "when the file type is not accepted" do
let(:file_attachments) { [as_adu(fixture_file_upload(Rails.root.join("spec/fixtures/support/bad.php"), "application/x-httpd-php"))] }

it "makes the email invalid" do
expect(draft_email).not_to be_valid
expect(draft_email.errors[:file_attachments]).to include("One or more of the files you uploaded was an incorrect file type")
end
end
end

describe "coming from the email template" do
let(:template_attachment) { create(:support_email_template_attachment) }
let(:blob_attachments) { "[{\"file_id\": \"#{template_attachment.id}\", \"type\": \"Support::EmailTemplateAttachment\"}]" }

it "appear in the list of attachments" do
expect(draft_email.attachments.count).to eq(1)
expect(draft_email.attachments.first.content_type).to eq("text/plain")
expect(draft_email.attachments.first.name).to eq("attachment.txt")
expect(draft_email.attachments.first.content_bytes).to eq(Base64.encode64(template_attachment.file.download))
end
end
end
end

0 comments on commit 61f3418

Please sign in to comment.