-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
describe "DeprecationWarningSubscriber" do | ||
let(:rails_logger) { Rails.logger } | ||
let(:slack_service) { SlackService.new(url: "dummy-url") } | ||
|
||
before do | ||
allow(Rails).to receive(:logger).and_return(rails_logger) | ||
allow(rails_logger).to receive(:warn) | ||
|
||
describe "DeprecationWarningSubscriber" do | ||
let(:rails_logger) { Rails.logger } | ||
let(:slack_service) { SlackService.new(url: "dummy-url") } | ||
|
||
before do | ||
allow(Rails).to receive(:logger).and_return(rails_logger) | ||
allow(rails_logger).to receive(:warn) | ||
|
||
allow(Raven).to receive(:capture_message) | ||
|
||
allow(SlackService).to receive(:new).with(url: anything).and_return(slack_service) | ||
allow(slack_service).to receive(:send_notification) | ||
allow(Raven).to receive(:capture_message) | ||
|
||
allow(SlackService).to receive(:new).with(url: anything).and_return(slack_service) | ||
allow(slack_service).to receive(:send_notification) | ||
end | ||
|
||
context "when a 'deprecation.rails' event is instrumented" do | ||
let(:payload) { { message: "test message", callstack: "test callstack" } } | ||
|
||
before { ActiveSupport::Notifications.instrument("deprecation.rails", payload) } | ||
|
||
it "emits a warning to the application logs" do | ||
Check failure on line 22 in spec/initializers/deprecation_warning_subscriber_spec.rb GitHub Actions / rake
|
||
expect(rails_logger).to have_received(:warn).with(payload[:message]) | ||
end | ||
|
||
it "emits a warning to Sentry" do | ||
Check failure on line 26 in spec/initializers/deprecation_warning_subscriber_spec.rb GitHub Actions / rake
|
||
expect(Raven).to have_received(:capture_message).with( | ||
payload[:message], | ||
level: "warning", | ||
extra: { | ||
message: payload[:message], | ||
callstack: payload[:callstack], | ||
environment: Rails.env | ||
} | ||
) | ||
end | ||
|
||
context "when a 'deprecation.rails' event is instrumented" do | ||
let(:payload) { { message: "test message", callstack: "test callstack" } } | ||
|
||
before { ActiveSupport::Notifications.instrument("deprecation.rails", payload) } | ||
|
||
it "emits a warning to the application logs" do | ||
expect(rails_logger).to have_received(:warn).with(payload[:message]) | ||
end | ||
|
||
it "emits a warning to Sentry" do | ||
expect(Raven).to have_received(:capture_message).with( | ||
payload[:message], | ||
level: "warning", | ||
extra: { | ||
message: payload[:message], | ||
callstack: payload[:callstack], | ||
environment: Rails.env | ||
} | ||
) | ||
end | ||
|
||
it "emits a warning to Slack channel" do | ||
expect(slack_service).to have_received(:send_notification).with( | ||
payload[:message], | ||
"Deprecation Warning", | ||
"#appeals-deprecation-alerts" | ||
) | ||
end | ||
|
||
it "emits a warning to Slack channel" do | ||
Check failure on line 38 in spec/initializers/deprecation_warning_subscriber_spec.rb GitHub Actions / rake
|
||
expect(slack_service).to have_received(:send_notification).with( | ||
payload[:message], | ||
"Deprecation Warning", | ||
"#appeals-deprecation-alerts" | ||
) | ||
end | ||
end | ||
end | ||
end |