Skip to content

Commit ff61c4c

Browse files
author
matt swanson
committed
Merge pull request stringer-rss#256 from jmazzi/bugfix/fever_group_0
Mark all items read when the fever group_id is 0
2 parents 2b0e5f5 + dd09be4 commit ff61c4c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
require_relative "../../repositories/story_repository"
22

33
class MarkGroupAsRead
4+
KINDLING_GROUP_ID = 1
5+
SPARKS_AND_KINDLING_GROUP_ID = 0
6+
47
def initialize(group_id, timestamp, repository = StoryRepository)
58
@group_id = group_id.to_i
69
@repo = repository
710
@timestamp = timestamp
811
end
912

1013
def mark_group_as_read
11-
@repo.fetch_unread_by_timestamp(@timestamp).update_all(is_read: true) if @group_id == 1
14+
if [SPARKS_AND_KINDLING_GROUP_ID, KINDLING_GROUP_ID].include? @group_id
15+
@repo.fetch_unread_by_timestamp(@timestamp).update_all(is_read: true)
16+
end
1217
end
1318
end
1419

‎spec/commands/stories/mark_group_as_read_spec.rb‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
let(:stories) { stub }
88
let(:repo){ stub(fetch_unread_by_timestamp: stories) }
99

10+
it "marks group 0 as read" do
11+
command = MarkGroupAsRead.new(0, Time.now.to_i, repo)
12+
stories.should_receive(:update_all).with(is_read: true)
13+
command.mark_group_as_read
14+
end
15+
1016
it "marks group 1 as read" do
1117
command = MarkGroupAsRead.new(1, Time.now.to_i, repo)
1218
stories.should_receive(:update_all).with(is_read: true)

0 commit comments

Comments
 (0)