FIX: Parsing non-existent feed should not fail
This commit is contained in:
parent
865cb3feb9
commit
b73950692b
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue