Skip to content

Commit

Permalink
fixup! Extract FoiAttachment::Dsn & restore functionality
Browse files Browse the repository at this point in the history
Add FoiAttachment#extra_note spec
  • Loading branch information
garethrees committed Dec 1, 2023
1 parent d91f166 commit f1feed2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/factories/foi_attchments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/files/attachment.delivery_status
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
X-Symantec-Messaging-Gateway-Queue-ID: EE/CD-06721-9C109DE4
X-Symantec-Messaging-Gateway-Sender: rfc822; [email protected]
Reporting-MTA: dns; gov.example.com
Arrival-Date: Sat, 03 Dec 2011 04:50:17 +0000

Final-Recipient: rfc822; [email protected]
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
22 changes: 22 additions & 0 deletions spec/models/foi_attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
'<em>DSN: 4.4.0 Other or undefined network or routing status</em>'
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

0 comments on commit f1feed2

Please sign in to comment.