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 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
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
16 changes: 15 additions & 1 deletion spec/airbrake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
'https://airbrake.io/api/v3/projects/113743/notices?key=fd04e13d806a90f96614ad8e529b2822'
end

before do
let!(:notifier) do
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need the !, here, unless I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise some tests start failing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it now :-)

described_class.configure do |c|
c.project_id = 113743
c.project_key = 'fd04e13d806a90f96614ad8e529b2822'
end
end

before do
stub_request(:post, endpoint).to_return(status: 201, body: '{}')
end

Expand Down Expand Up @@ -161,6 +163,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