Skip to content

Commit

Permalink
Merge pull request #295 from mikehale/fix-rollbar-scope-extraction
Browse files Browse the repository at this point in the history
Fix rollbar scope extraction
  • Loading branch information
gudmundur authored Jan 6, 2017
2 parents ced8bf0 + 957fe6d commit fa9296a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pliny/error_reporters/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def notify(exception, context:, rack_env:)

def fetch_scope(context:, rack_env:)
scope = {}
if rack_env.respond_to?(:body)
unless rack_env.empty?
scope[:request] = proc { extract_request_data_from_rack(rack_env) }
end
scope
Expand Down
6 changes: 5 additions & 1 deletion spec/error_reporters/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
describe "#notify" do
let(:exception) { StandardError.new("Something went wrong") }
let(:context) { {} }
let(:rack_env) { double(:rack_env, body: StringIO.new) }
let(:rack_env) { { "rack.input" => StringIO.new } }

subject(:notify) do
reporter.notify(exception, context: context, rack_env: rack_env)
Expand Down Expand Up @@ -41,6 +41,10 @@
context "given an empty rack_env" do
let(:rack_env) { {} }

it "expects rack_env to be a hash" do
assert_kind_of(Hash, rack_env)
end

it "reports to Rollbar with an empty scope" do
notify
expect(Rollbar).to have_received(:scoped).once.with({})
Expand Down

0 comments on commit fa9296a

Please sign in to comment.