forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_old_stories_spec.rb
More file actions
52 lines (39 loc) · 1.55 KB
/
remove_old_stories_spec.rb
File metadata and controls
52 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'
app_require 'tasks/remove_old_stories'
describe RemoveOldStories do
describe '.remove!' do
let(:stories_mock) do
stories = double('stories')
stories.stub(:delete_all)
stories
end
it 'should pass along the number of days to the story repository query' do
RemoveOldStories.stub(:pruned_feeds){ [] }
StoryRepository.should_receive(:unstarred_read_stories_older_than).with(7).and_return(stories_mock)
RemoveOldStories.remove!(7)
end
it 'should request deletion of all old stories' do
RemoveOldStories.stub(:pruned_feeds){ [] }
StoryRepository.stub(:unstarred_read_stories_older_than){ stories_mock }
stories_mock.should_receive(:delete_all)
RemoveOldStories.remove!(11)
end
it 'should fetch affected feeds by id' do
RemoveOldStories.stub(:old_stories) do
stories = [double('story', feed_id: 3), double('story', feed_id: 5)]
stories.stub(:delete_all)
stories
end
FeedRepository.should_receive(:fetch_by_ids).with([3, 5]).and_return([])
RemoveOldStories.remove!(13)
end
it 'should update last_fetched on affected feeds' do
feeds = [double('feed a'), double('feed b')]
RemoveOldStories.stub(:pruned_feeds){ feeds }
RemoveOldStories.stub(:old_stories){ stories_mock }
FeedRepository.should_receive(:update_last_fetched).with(feeds.first, anything())
FeedRepository.should_receive(:update_last_fetched).with(feeds.last, anything())
RemoveOldStories.remove!(13)
end
end
end