combine Rack::Timeout::RequestTimeoutErrors with Exceptions in Honeybadger (#5789) [deploy]

This commit is contained in:
Molly Struve 2020-01-28 16:55:51 -05:00 committed by GitHub
parent 82f2281b1c
commit a19ce5518e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 38 deletions

View file

@ -4,6 +4,7 @@
MESSAGE_FINGERPRINTS = {
"BANNED" => "banned",
"Rack::Timeout::RequestTimeoutException" => "rack_timeout",
"Rack::Timeout::RequestTimeoutError" => "rack_timeout",
"PG::QueryCanceled" => "pg_query_canceled"
}.freeze

View file

@ -1,34 +1,8 @@
require "rails_helper"
describe Honeybadger do
context "when a fetch_all_rss SIGTERM error is raised" do
it "sets fingerprint to error_message" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "SignalException: SIGTERM", component: "rake fetch_all_rss"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq(notice.error_message)
end
end
context "when BANNED error is raised" do
it "sets fingerprint to banned" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "RuntimeError: BANNED"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("banned")
end
end
context "when Rack::Timeout::RequestTimeoutException is raised" do
it "sets fingerprint to rack_timeout" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "Rack::Timeout::RequestTimeoutException happened"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("rack_timeout")
end
MESSAGE_FINGERPRINTS.each do |error_key, fingerprint|
include_examples "#sets_correct_honeybadger_fingerprint", error_key, fingerprint
end
context "when error is raised from an internal route" do
@ -40,14 +14,4 @@ describe Honeybadger do
expect(notice.fingerprint).to eq("internal")
end
end
context "when a PG::QueryCanceled error is raised" do
it "sets fingerprint to pg_query_cancel" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "ActionView::Template::Error: PG::QueryCanceled:"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("pg_query_canceled")
end
end
end

View file

@ -0,0 +1,9 @@
RSpec.shared_examples "#sets_correct_honeybadger_fingerprint" do |error_key, fingerprint|
it "raises an error" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "CRAP! #{error_key} Bail!"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq(fingerprint)
end
end

View file

@ -34,6 +34,7 @@ Dir[Rails.root.join("spec/system/shared_examples/**/*.rb")].sort.each { |f| requ
Dir[Rails.root.join("spec/models/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/jobs/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/workers/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/initializers/shared_examples/**/*.rb")].sort.each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.