Skip to content

Commit

Permalink
Merge pull request #480 from rollbar/fix-item-build_with
Browse files Browse the repository at this point in the history
Pass correct options to Item.build_with
  • Loading branch information
jondeandres committed Jun 3, 2016
2 parents dc9f42c + edc3179 commit 16fdc95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def process_item(item)
def process_from_async_handler(payload)
payload = Rollbar::JSON.load(payload) if payload.is_a?(String)

item = Item.build_with(payload)
item = Item.build_with(payload,
:notifier => self,
:configuration => configuration,
:logger => logger)

Rollbar.silenced do
begin
Expand Down Expand Up @@ -263,7 +266,11 @@ def send_failsafe(message, exception)
}

begin
schedule_item(Item.build_with(failsafe_payload))
item = Item.build_with(failsafe_payload,
:notifier => self,
:configuration => configuration,
:logger => logger)
schedule_item(item)
rescue => e
log_error "[Rollbar] Error sending failsafe : #{e}"
end
Expand Down
21 changes: 21 additions & 0 deletions spec/rollbar/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,5 +631,26 @@
expect(json).to be_kind_of(String)
end
end

context 'with too large payload', :fixture => :payload do
let(:payload_fixture) { 'payloads/sample.trace.json' }
let(:item) do
Rollbar::Item.build_with(payload,
:notifier => notifier,
:configuration => configuration,
:logger => logger)
end

before do
allow(Rollbar::Truncation).to receive(:truncate?).and_return(true)
end

it 'calls Notifier#send_failsafe and logs the error' do
expect(notifier).to receive(:send_failsafe)
expect(logger).to receive(:error)

item.dump
end
end
end
end

0 comments on commit 16fdc95

Please sign in to comment.