Skip to content

Commit

Permalink
Don’t silence optional target exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
markedmondson committed Feb 9, 2021
1 parent 1b4a90b commit 01a1fe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/activity_notification/apis/notification_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def publish_to_optional_targets(options = {})
[optional_target_name, true]
rescue => e
Rails.logger.error(e)
[optional_target_name, e]
raise e
end
else
[optional_target_name, false]
Expand Down
14 changes: 11 additions & 3 deletions spec/concerns/apis/notification_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,17 @@
Comment._optional_targets[:users] = @current_optional_target
end

it "generates notifications even if some optional targets raise error" do
notifications = described_class.notify(:users, @comment_2)
expect(notifications.size).to eq(2)
it "raises an capturable exception" do
expect { described_class.notify(:users, @comment_2) }.to raise_error(RuntimeError)
end

it "allows an exception to be captured to continue" do
begin
notifications = described_class.notify(:users, @comment_2)
expect(notifications.size).to eq(2)
rescue => e
next
end
end
end
end
Expand Down

0 comments on commit 01a1fe9

Please sign in to comment.