From 41c2995cff26b7303db265dc73247d3d2b5b98bb Mon Sep 17 00:00:00 2001 From: James Mason Date: Mon, 19 Nov 2018 19:05:53 -0800 Subject: [PATCH] test for missing logo --- .rubocop_todo.yml | 1 + spec/pdfs/ticket_pdf_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f37b3180..9929b1c2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -777,6 +777,7 @@ RSpec/SubjectStub: RSpec/VerifiedDoubles: Exclude: - 'spec/datatables/user_datatable_spec.rb' + - 'spec/pdfs/ticket_pdf_spec.rb' # Offense count: 1 RSpec/VoidExpect: diff --git a/spec/pdfs/ticket_pdf_spec.rb b/spec/pdfs/ticket_pdf_spec.rb index fdbc195e..13ecd8ec 100644 --- a/spec/pdfs/ticket_pdf_spec.rb +++ b/spec/pdfs/ticket_pdf_spec.rb @@ -34,4 +34,22 @@ describe TicketPdf do expect(page_analysis.pages.length).to eq(1) expect(page_analysis.pages.first[:strings]).to include(conference.title) end + + it 'handles bad logo urls' do + allow(conference).to receive(:picture?).and_return(true) + allow(conference).to receive(:picture) do + double('picture', ticket: double('ticket', url: 'http://broken/link.png')) + end + stub_request(:get, 'http://broken/link.png') + .with( + headers: { + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' + }) + .to_return(status: 404, body: '', headers: {}) + + pdf = described_class.new(conference, participant, physical_ticket, layout, file_name) + expect{ PDF::Inspector::Page.analyze(pdf.render) }.to_not raise_error(OpenURI::HTTPError) + end end