Skip to content

Commit 2ecc679

Browse files
author
Matt Swanson
committed
Merge branch 'master' of github.com:swanson/stringer
2 parents c7e945c + ff61c4c commit 2ecc679

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
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)