diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 94f5666d8..59fb5cf6b 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -96,7 +96,11 @@ def self.extract_content(entry) sanitized_content = sanitize(entry.summary) end - expand_absolute_urls(sanitized_content, entry.url) + if entry.url.present? + expand_absolute_urls(sanitized_content, entry.url) + else + sanitized_content + end end def self.extract_title(entry) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 75a73dbe0..fa392abdd 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -85,6 +85,22 @@ it "falls back to summary if there is no content" do expect(StoryRepository.extract_content(summary_only)).to eq "Dumb publisher" end + + it "expands urls" do + entry = double(url: "http://mdswanson.com", + content: nil, + summary: "Page") + + expect(StoryRepository.extract_content(entry)).to eq "Page" + end + + it "ignores URL expansion if entry url is nil" do + entry = double(url: nil, + content: nil, + summary: "Page") + + expect(StoryRepository.extract_content(entry)).to eq "Page" + end end describe ".sanitize" do