diff --git a/app/jobs/scheduled/poll_feed.rb b/app/jobs/scheduled/poll_feed.rb index 098615bb679..7567660a42d 100644 --- a/app/jobs/scheduled/poll_feed.rb +++ b/app/jobs/scheduled/poll_feed.rb @@ -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 diff --git a/spec/jobs/poll_feed_spec.rb b/spec/jobs/poll_feed_spec.rb index 8c3e3cf22ab..ce79bdb3049 100644 --- a/spec/jobs/poll_feed_spec.rb +++ b/spec/jobs/poll_feed_spec.rb @@ -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