Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated option #14

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
13 changes: 2 additions & 11 deletions lib/adhearsion/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ class Plugin < Adhearsion::Plugin
api_key nil, desc: "The Airbrake/Errbit API key"
url "http://airbrake.io", desc: "Base URL for notification service"
app_name "Adhearsion", desc: "Application name, used for reporting"
notifier Adhearsion::Reporter::AirbrakeNotifier,
desc: "The class that will act as the notifier. Built-in classes are Adhearsion::Reporter::AirbrakeNotifier, Adhearsion::Reporter::NewrelicNotifier, and Adhearsion::Reporter::SentryNotifier. This option is deprecated; please specify in `notifiers`.",
transform: Proc.new { |v| const_get(v.to_s) }
notifiers [],
desc: "Collection of classes that will act as notifiers",
notifiers [Adhearsion::Reporter::AirbrakeNotifier],
desc: "Collection of classes that will act as notifiers (comma-separated). Built-in classes are Adhearsion::Reporter::AirbrakeNotifier, Adhearsion::Reporter::NewrelicNotifier, and Adhearsion::Reporter::SentryNotifier.",
transform: Proc.new { |v| v.split(',').map { |n| n.to_s.constantize } }
enable true, desc: "Whether to send notifications - set to false to disable all notifications globally (useful for testing)"
excluded_environments [:development, :test], desc: "Skip reporting errors for the listed environments (comma delimited when set by environment variable", transform: Proc.new { |v| names = v.split(','); names = names.each.map &:to_sym }
Expand All @@ -45,12 +42,6 @@ class Plugin < Adhearsion::Plugin
end

init :reporter do
# If a collection of multiple notifiers is not set, fall back to the individual option for BC.
# TODO: Remove the `notifier` option in v3.0
if Reporter.config.notifiers.empty?
Reporter.config.notifiers = [Reporter.config.notifier]
end

Reporter.config.notifiers.each do |notifier|
notifier.init
Events.register_callback(:exception) do |e, logger|
Expand Down
15 changes: 7 additions & 8 deletions spec/reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
ExceptionClass = Class.new StandardError

before do
Adhearsion::Reporter.config.notifier = nil
Adhearsion::Reporter.config.notifiers = []
end

Expand All @@ -27,24 +26,24 @@ def self.method_missing(m, *args, &block)
end

before(:each) do
Adhearsion::Reporter.config.notifier = DummyNotifier
Adhearsion::Reporter.config.notifiers = [DummyNotifier]
Adhearsion::Plugin.init_plugins
Adhearsion::Events.trigger_immediately :exception, ExceptionClass.new
end

it "calls init on the notifier instance" do
expect(Adhearsion::Reporter.config.notifier.instance.initialized).to be(true)
expect(DummyNotifier.instance.initialized).to be(true)
end

it "logs an exception event" do
sleep 0.25
expect(Adhearsion::Reporter.config.notifier.instance.notified.class).to eq(ExceptionClass)
expect(DummyNotifier.instance.notified.class).to eq(ExceptionClass)
end
end

context "with a AirbrakeNotifier" do
before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::AirbrakeNotifier
Adhearsion::Reporter.config.notifiers = [Adhearsion::Reporter::AirbrakeNotifier]
end

it "should initialize correctly" do
Expand Down Expand Up @@ -90,7 +89,7 @@ def self.method_missing(m, *args, &block)

context "with a NewrelicNotifier" do
before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::NewrelicNotifier
Adhearsion::Reporter.config.notifiers = [Adhearsion::Reporter::NewrelicNotifier]
end

it "should initialize correctly" do
Expand Down Expand Up @@ -129,7 +128,7 @@ def self.method_missing(m, *args, &block)
let(:error_message) { "Something bad" }

before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::EmailNotifier
Adhearsion::Reporter.config.notifiers = [Adhearsion::Reporter::EmailNotifier]
Adhearsion::Reporter.config.email = email_options
end

Expand Down Expand Up @@ -169,7 +168,7 @@ def self.method_missing(m, *args, &block)
end

before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::SentryNotifier
Adhearsion::Reporter.config.notifiers = [Adhearsion::Reporter::SentryNotifier]
Adhearsion::Reporter.config.sentry = sentry_options
end

Expand Down