diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 4967d77ac..94f5666d8 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -82,7 +82,7 @@ def self.read_count end def self.extract_url(entry, feed) - return entry.enclosure_url if entry.url.nil? && entry.enclosure_url.present? + return entry.enclosure_url if entry.url.nil? && entry.respond_to?(:enclosure_url) normalize_url(entry.url, feed.url) unless entry.url.nil? end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index b7eed53bf..75a73dbe0 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -40,6 +40,13 @@ expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/swanson/stringer" end + + it "does not crash if url is nil but enclosure_url does not exist" do + feed = double(url: "http://github.com") + entry = double(url: nil) + + expect(StoryRepository.extract_url(entry, feed)).to eq nil + end end describe ".extract_title" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f2799081b..96039db07 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,9 +8,6 @@ require "ostruct" require "date" -require "coveralls" -Coveralls.wear! - require "factories/feed_factory" require "factories/story_factory" require "factories/user_factory"