Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/optimizely/notification_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ def send_notifications(notification_type, *args)
@logger.log Logger::INFO, "Notification #{notification_type} sent successfully."
rescue => e
@logger.log(Logger::ERROR, "Problem calling notify callback. Error: #{e}")
return nil
end

nil
end

def notification_count(notification_type)
Expand Down
13 changes: 13 additions & 0 deletions spec/notification_center_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,19 @@ def deliver_three; end
.with(Logger::INFO, 'delivered two.')
end

it 'should keep calling remaining listeners when an earlier listener raises' do
notification_type = Optimizely::NotificationCenter::NOTIFICATION_TYPES[:ACTIVATE]
failing = ->(_args) { raise 'listener failure' }
notification_center.add_notification_listener(notification_type, failing)
notification_center.add_notification_listener(notification_type, invitation.method(:deliver_two))

expect { notification_center.send_notifications(notification_type, @args) }.to_not raise_error
expect(spy_logger).to have_received(:log)
.with(Logger::ERROR, 'Problem calling notify callback. Error: listener failure')
expect(spy_logger).to have_received(:log).once
.with(Logger::INFO, 'delivered two.')
end

it 'should send notifications and verify that all callbacks are called' do
notification_type_decision = Optimizely::NotificationCenter::NOTIFICATION_TYPES[:ACTIVATE]
notification_type_track = Optimizely::NotificationCenter::NOTIFICATION_TYPES[:TRACK]
Expand Down