fix issue in activity logger
This commit is contained in:
parent
a622b0b947
commit
240160f877
2 changed files with 20 additions and 1 deletions
|
@ -13,7 +13,11 @@ class ActivityLogger
|
|||
end
|
||||
|
||||
def self.log(id, event)
|
||||
@@loggers[id].each { |logger| logger.write event }
|
||||
@@loggers[id].each do |logger|
|
||||
logger.write event
|
||||
rescue
|
||||
puts 'rescued'
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset
|
||||
|
|
|
@ -29,6 +29,21 @@ RSpec.describe ActivityLogger do
|
|||
expect(sse2).to have_received(:write).with(event)
|
||||
end
|
||||
|
||||
it 'sends events to all listeners even if some fail' do
|
||||
sse1 = spy('sse1')
|
||||
sse2 = spy('sse2')
|
||||
event = double('event')
|
||||
|
||||
allow(sse1).to receive(:write).and_throw(:error)
|
||||
|
||||
ActivityLogger.register('test_id', sse1)
|
||||
ActivityLogger.register('test_id', sse2)
|
||||
|
||||
ActivityLogger.log('test_id', event)
|
||||
|
||||
expect(sse2).to have_received(:write).with(event)
|
||||
end
|
||||
|
||||
it 'does not send events to listeners of a different id' do
|
||||
sse = spy('sse')
|
||||
event = double('event')
|
||||
|
|
Loading…
Reference in a new issue