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

airbrake-ruby: fix add_filter block API #10

Merged
merged 2 commits into from
Dec 22, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
Airbrake Ruby Changelog
=======================

### master

* Fixed the `Airbrake.add_filter` block API
([#10](https://github.com/airbrake/airbrake-ruby/pull/10))

### [v1.0.0][v1.0.0] (December 18, 2015)

* Improved backtrace parsing support ([#4](https://github.com/airbrake/airbrake-ruby/pull/4))
* Improved backtrace parsing support
([#4](https://github.com/airbrake/airbrake-ruby/pull/4))

### [v1.0.0.rc.1][v1.0.0.rc.1] (December 11, 2015)

Expand Down
4 changes: 2 additions & 2 deletions lib/airbrake-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ def create_deploy(deploy_params, notifier = :default)
# Calls +method+ on +notifier+ with provided +args+.
#
# @raise [Airbrake::Error] if none of the notifiers exist
def call_notifier(notifier, method, *args)
def call_notifier(notifier, method, *args, &block)
if @notifiers.key?(notifier)
@notifiers[notifier].__send__(method, *args)
@notifiers[notifier].__send__(method, *args, &block)
else
raise Airbrake::Error,
"the '#{notifier}' notifier isn't configured"
Expand Down
14 changes: 13 additions & 1 deletion spec/airbrake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

before do
described_class.configure do |c|
@notifier = described_class.configure do |c|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be more consistent as a let or subject?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let or subject cache their values, don't they? Here we need to reset the notifier to make sure that we always use a fresh one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks. Replaced with let!. PTAL

c.project_id = 113743
c.project_key = 'fd04e13d806a90f96614ad8e529b2822'
end
Expand Down Expand Up @@ -161,6 +161,18 @@

describe ".add_filter" do
include_examples 'error handling', :add_filter

it "adds filters with help of blocks" do
filter_chain = @notifier.instance_variable_get(:@filter_chain)
filters = filter_chain.instance_variable_get(:@filters)

expect(filters.size).to eq(2)

described_class.add_filter {}

expect(filters.size).to eq(3)
expect(filters.last).to be_a(Proc)
end
end

describe ".whitelist_keys" do
Expand Down