From 2bb97b53bc2ded964fcf8fcc98465ae0a2775f3c Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Thu, 27 Oct 2016 09:06:00 +0900 Subject: [PATCH] Add failing specs for empty `` elements --- spec/models/agents/rss_agent_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/models/agents/rss_agent_spec.rb b/spec/models/agents/rss_agent_spec.rb index 67a4a520..0d01cea8 100644 --- a/spec/models/agents/rss_agent_spec.rb +++ b/spec/models/agents/rss_agent_spec.rb @@ -8,8 +8,10 @@ describe Agents::RssAgent do } stub_request(:any, /github.com/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/github_rss.atom")), :status => 200) + stub_request(:any, /bad.github.com/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/github_rss.atom")).gsub(/]+\/>/, ''), status: 200) stub_request(:any, /SlickdealsnetFP/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/slickdeals.atom")), :status => 200) stub_request(:any, /onethingwell.org/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/onethingwell.rss")), status: 200) + stub_request(:any, /bad.onethingwell.org/).to_return(body: File.read(Rails.root.join("spec/data_fixtures/onethingwell.rss")).gsub(/(?<=)[^<]*/, ''), status: 200) end let(:agent) do @@ -257,6 +259,30 @@ describe Agents::RssAgent do event = agent.events.first expect(event.payload['authors']).to eq([]) end + + context 'with an empty link in RSS' do + before do + @valid_options['url'] = 'http://bad.onethingwell.org/rss' + end + + it "does not leak :no_buffer" do + agent.check + event = agent.events.first + expect(event.payload['links']).to eq([]) + end + end + + context 'with an empty link in RSS' do + before do + @valid_options['url'] = "https://bad.github.com/cantino/huginn/commits/master.atom" + end + + it "does not leak :no_buffer" do + agent.check + event = agent.events.first + expect(event.payload['links']).to eq([]) + end + end end describe 'logging errors with the feed url' do