Skip to content
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
6 changes: 1 addition & 5 deletions lib/raven/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ def current_environment=(environment)
end

def send_in_current_environment?
if environments
environments.include?(current_environment)
else
true
end
!!server && (!environments || environments.include?(current_environment))
end

def log_excluded_environment_message
Expand Down
8 changes: 3 additions & 5 deletions lib/raven/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ def initialize(options = {}, &block)

block.call(self) if block

if @configuration.send_in_current_environment?
if !self[:http] && context.rack_env
self.interface :http do |int|
int.from_rack(context.rack_env)
end
if !self[:http] && context.rack_env
self.interface :http do |int|
int.from_rack(context.rack_env)
end
end

Expand Down
36 changes: 17 additions & 19 deletions spec/raven/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
end
end

context 'being initialized without server configuration' do
before do
subject.environments = %w[ test ]
end

it 'should not send events' do
expect(subject[:server]).to eq(nil)
expect(subject.send_in_current_environment?).to eq(false)
end
end

context 'being initialized with a server string' do
before do
subject.server = 'http://12345:67890@sentry.localdomain/sentry/42'
Expand Down Expand Up @@ -87,11 +98,7 @@
it_should_behave_like 'a complete configuration'
end

context 'being initialized in a non-test environment' do
it 'should send events' do
expect(subject.send_in_current_environment?).to eq(true)
end

context 'configuring for async' do
it 'should be configurable to send events async' do
subject.async = lambda { |_e| :ok }
expect(subject.async.respond_to?(:call)).to eq(true)
Expand All @@ -104,31 +111,22 @@
expect { subject.async = false }.to_not raise_error
expect { subject.async = true }.to raise_error(ArgumentError)
end

end

context 'being initialized in a test environment' do
context 'being initialized with a current environment' do
before(:each) do
subject.current_environment = 'test'
end

it 'should send events' do
expect(subject.send_in_current_environment?).to eq(true)
subject.server = 'http://sentry.localdomain/sentry'
end

it 'should send events if test is whitelisted' do
subject.environments = %w[ test ]
expect(subject.send_in_current_environment?).to eq(true)
end
end

context 'being initialized in a development environment' do
before(:each) do
subject.current_environment = 'development'
end

it 'should send events' do
expect(subject.send_in_current_environment?).to eq(true)
it 'should not send events if test is not whitelisted' do
subject.environments = %w[ not_test ]
expect(subject.send_in_current_environment?).to eq(false)
end
end

Expand Down
6 changes: 5 additions & 1 deletion spec/support/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ require 'rake'
require 'rubygems'
require 'raven'

Raven.configure do |config|
config.dsn = 'http://12345:67890@sentry.localdomain/sentry/42'
end

task :raise_exception do
1 / 0
end
end