Commit c448138a9051b9b78878692983ec0968b7c7bcc7
1 parent
8c98210c
Exists in
master
and in
14 other branches
FeedHandler: correctly handle feeds that were never fetched
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
lib/feed_handler.rb
| ... | ... | @@ -108,7 +108,7 @@ class FeedHandler |
| 108 | 108 | end |
| 109 | 109 | |
| 110 | 110 | def enough_time_since_last_failure(container) |
| 111 | - container.fetched_at < (Time.now - FeedHandler.disabled_period) | |
| 111 | + container.fetched_at.nil? || container.fetched_at < (Time.now - FeedHandler.disabled_period) | |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | 114 | end | ... | ... |
test/unit/feed_handler_test.rb
| ... | ... | @@ -132,6 +132,14 @@ class FeedHandlerTest < ActiveSupport::TestCase |
| 132 | 132 | |
| 133 | 133 | assert container.enabled, 'must reenable container after <disabled_period> (%s)' % container_class |
| 134 | 134 | end |
| 135 | + | |
| 136 | + should "handle a feed that was never fetched successfully (#{container_class})" do | |
| 137 | + container = create(container_class) | |
| 138 | + container.update_errors = FeedHandler.max_errors + 1 | |
| 139 | + container.fetched_at = nil | |
| 140 | + handler.expects(:actually_process_container).with(container) | |
| 141 | + handler.process(container) | |
| 142 | + end | |
| 135 | 143 | end |
| 136 | 144 | |
| 137 | 145 | should 'not crash even when finish fetch fails' do | ... | ... |