diff --git a/spec/factories/foi_attchments.rb b/spec/factories/foi_attchments.rb index 650a9f7df60..42f4144e28c 100644 --- a/spec/factories/foi_attchments.rb +++ b/spec/factories/foi_attchments.rb @@ -61,6 +61,12 @@ body { 'someimage' } end + factory :delivery_status_notification_attachment do + content_type { 'message/delivery-status' } + filename { 'attachment.delivery_status' } + body { load_file_fixture('attachment.delivery_status') } + end + factory :unknown_attachment do content_type { 'application/unknown' } filename { 'interesting.spc' } diff --git a/spec/fixtures/files/attachment.delivery_status b/spec/fixtures/files/attachment.delivery_status new file mode 100644 index 00000000000..2ad43a66ac3 --- /dev/null +++ b/spec/fixtures/files/attachment.delivery_status @@ -0,0 +1,10 @@ +X-Symantec-Messaging-Gateway-Queue-ID: EE/CD-06721-9C109DE4 +X-Symantec-Messaging-Gateway-Sender: rfc822; foi@gov.example.com +Reporting-MTA: dns; gov.example.com +Arrival-Date: Sat, 03 Dec 2011 04:50:17 +0000 + +Final-Recipient: rfc822; foi@gov.example.com +Status: 4.4.0 +Action: delayed +Last-Attempt-Date: Sat, 03 Dec 2011 04:50:17 +0000 +Diagnostic-Code: smtp; 421 4.4.0 [internal] no MXs for this domain could be reached at this time diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb index f1de59d5d0b..94dcbedb9c4 100644 --- a/spec/models/foi_attachment_spec.rb +++ b/spec/models/foi_attachment_spec.rb @@ -374,4 +374,26 @@ it { is_expected.to be_nil } end end + + describe '#extra_note' do + subject { foi_attachment.extra_note } + + context 'with a delivery status notification' do + let(:foi_attachment) do + FactoryBot.create(:delivery_status_notification_attachment) + end + + let(:note) do + 'DSN: 4.4.0 Other or undefined network or routing status' + end + + it { is_expected.to eq(note) } + it { is_expected.to be_html_safe } + end + + context 'with any other content type' do + let(:foi_attachment) { FactoryBot.build(:rtf_attachment) } + it { is_expected.to be_nil } + end + end end