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
3 changes: 1 addition & 2 deletions lib/raven/integrations/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def call(env)
raise
end

error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception']

error = env['rack.exception'] || env['sinatra.error']
Raven::Rack.capture_exception(error, env) if error

response
Expand Down
16 changes: 0 additions & 16 deletions spec/raven/integrations/rack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@
stack.call(env)
end

it 'should capture rails errors when ActionDispatch::ShowExceptions is enabled' do
exception = build_exception
env = {}

expect(Raven::Rack).to receive(:capture_exception).with(exception, env)

app = lambda do |e|
e['action_dispatch.exception'] = exception
[200, {}, ['okay']]
end

stack = Raven::Rack.new(app)

stack.call(env)
end

it 'should clear context after app is called' do
Raven::Context.current.tags[:environment] = :test

Expand Down
18 changes: 16 additions & 2 deletions spec/raven/integrations/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,31 @@
config.dsn = 'dummy://notaserver'
config.encoding = 'json'
end

Rails.env = "production"
TestApp.initialize!
end

after(:each) do
Raven.client.transport.events = []
end

it "inserts middleware" do
expect(TestApp.middleware).to include(Raven::Rack)
end

pending "should capture exceptions" do
it "should capture exceptions in production" do
get "/exception"
expect(response.status).to eq(500)
expect(Raven.client.transport.events.size).to eq(1)
end

it "should properly set the exception's URL" do
get "/exception"

# TODO: dummy transport shouldn't even encode the event
event = Raven.client.transport.events.first
event = JSON.parse!(event[1])

expect(event['request']['url']).to eq("http://www.example.com/exception")
end
end