FIX: Parsing non-existent feed should not fail

This commit is contained in:
Gerhard Schlager 2018-08-10 18:37:14 +02:00
parent 865cb3feb9
commit b73950692b
2 changed files with 13 additions and 0 deletions

View File

@ -89,6 +89,8 @@ module Jobs
def parsed_feed
raw_feed, encoding = fetch_rss
return nil if raw_feed.nil?
encoded_feed = Encodings.try_utf8(raw_feed, encoding) if encoding
encoded_feed = Encodings.to_utf8(raw_feed) unless encoded_feed

View File

@ -137,6 +137,17 @@ describe Jobs::PollFeed do
include_examples 'topic creation based on the the feed'
end
it "aborts when it can't fetch the feed" do
SiteSetting.feed_polling_enabled = true
SiteSetting.feed_polling_url = 'https://blog.discourse.org/feed/atom/'
SiteSetting.embed_by_username = 'eviltrout'
stub_request(:head, SiteSetting.feed_polling_url).to_return(status: 404)
stub_request(:get, SiteSetting.feed_polling_url).to_return(status: 404)
expect { poller.poll_feed }.to_not change { Topic.count }
end
context 'encodings' do
before do
SiteSetting.feed_polling_enabled = true