Skip to content

Commit

Permalink
Do not process unwatched walls. Closes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Eugene committed Nov 14, 2018
1 parent 627a3f5 commit 248210d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/db/vk_informer_chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def add(wall)

raise Vk::AlreadyWatching, data: wall, chat: self if watching? wall

wall.update_last if wall.chats.empty?
walls << wall
send_text t.chat.added(domain: wall.domain_escaped)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/db/vk_informer_wall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def keyboard_row
end

def self.process
find_each { |wall| wall.watched? ? wall.process : wall.update_last }
find_each { |wall| wall.process if wall.watched? }
end

private
Expand Down
6 changes: 6 additions & 0 deletions spec/unit_test/db/vk_informer_wall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
expect(@wall.send(:new_messages).size).to eq 3
end

it 'should not process unwatched walls' do
expect_any_instance_of(Vk::Wall).not_to receive(:process)

Vk::Wall.process
end

it 'should disable private walls' do
chat = FactoryBot.create(:chat, id: 1, enabled: false)

Expand Down

0 comments on commit 248210d

Please sign in to comment.