mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Alert ensures to pass metadata correctly
This commit is contained in:
@@ -23,6 +23,8 @@ class Alert
|
||||
def self.raise(error, metadata = {}, &block)
|
||||
Bugsnag.notify(error) do |payload|
|
||||
metadata.each do |name, data|
|
||||
# Bugsnag only reports metadata when given a Hash.
|
||||
data = { data: } unless data.is_a?(Hash)
|
||||
payload.add_metadata(name, data)
|
||||
end
|
||||
block.call(payload)
|
||||
|
||||
@@ -41,6 +41,14 @@ RSpec.describe Alert do
|
||||
)
|
||||
end
|
||||
|
||||
it "adds context given as keyword argument" do
|
||||
expect_any_instance_of(Bugsnag::Report).to receive(:add_metadata).with(
|
||||
:data, { data: "ABC123" }
|
||||
)
|
||||
|
||||
Alert.raise("hey", data: "ABC123")
|
||||
end
|
||||
|
||||
it "is compatible with Bugsnag API" do
|
||||
expect_any_instance_of(Bugsnag::Report).to receive(:add_metadata).with(
|
||||
:order, { number: "ABC123" }
|
||||
|
||||
Reference in New Issue
Block a user