Skip to content

Commit

Permalink
Merge pull request #8 from jonah-williams/reset_notifier_before_first…
Browse files Browse the repository at this point in the history
…_fork

Reset notifier before first fork
  • Loading branch information
dmeremyanin committed Dec 4, 2014
2 parents 068cdfd + 5b78b23 commit 7197921
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ rvm:
- jruby-19mode
- rbx
gemfile:
- gemfiles/rollbar-0.8.x.gemfile
- gemfiles/rollbar-1.0.x.gemfile
- gemfiles/rollbar-1.2.x.gemfile
matrix:
allow_failures:
- rvm: rbx
Expand Down
14 changes: 0 additions & 14 deletions gemfiles/rollbar-1.0.x.gemfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'rollbar', '~> 0.8.0'
gem 'rollbar', '~> 1.2.0'
gemspec :path => '../'

platforms :rbx do
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/failure/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Resque
module Failure
class Rollbar < Base
def save
::Rollbar.report_exception(exception, payload)
::Rollbar.error(exception, payload)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/resque/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
::Rollbar.configure do |config|
config.use_async = false
end
::Rollbar.reset_notifier!
end
2 changes: 1 addition & 1 deletion resque-rollbar.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']

gem.add_dependency 'resque'
gem.add_dependency 'rollbar', '>= 0.8'
gem.add_dependency 'rollbar', '>= 1.2'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'json'
Expand Down
2 changes: 1 addition & 1 deletion spec/resque/failure/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
queue = 'test'
payload = { 'class' => Object, 'args' => 89 }

expect(Rollbar).to receive(:report_exception).with(exception, payload)
expect(Rollbar.notifier).to receive(:log).with('error', exception, payload)
backend = Resque::Failure::Rollbar.new(exception, worker, queue, payload)
backend.save
end
Expand Down
40 changes: 34 additions & 6 deletions spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
require 'spec_helper'

describe Rollbar do
describe '#configuration' do
let(:configuration) { described_class.configuration }
describe 'resque-rollbar' do
describe Resque, :before_first_fork do
context 'when Rollbar has been configured to use resque' do
before do
Rollbar.configure do |config|
config.use_resque
end

describe '#use_async' do
subject { configuration.use_async }
it { is_expected.to be false }
Resque.before_first_fork.each do |hook|
hook.call
end
end

it 'disables asyc reporting from the resque process' do
expect(Rollbar.configuration.use_async).to be_falsey
end
end

context 'when a notifier has been created prior to configuration' do
let!(:unconfigured_notifier) { Rollbar.notifier }

before do
Rollbar.configure do |config|
config.use_resque
end

Resque.before_first_fork.each do |hook|
hook.call
end
end

it 'resets the notifier' do
expect(unconfigured_notifier).to be
expect(Rollbar.notifier).not_to be(unconfigured_notifier)
end
end
end
end

0 comments on commit 7197921

Please sign in to comment.