Skip to content

Commit 2a23c63

Browse files
committed
Merge pull request #422 from nateberkopec/rails-fix-multi-exception
WIP: Fix Rails multi-exception reports
2 parents 9108e36 + 037baab commit 2a23c63

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

lib/raven/integrations/rack.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def call(env)
5959
raise
6060
end
6161

62-
error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception']
63-
62+
error = env['rack.exception'] || env['sinatra.error']
6463
Raven::Rack.capture_exception(error, env) if error
6564

6665
response

spec/raven/integrations/rack_spec.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@
4646
stack.call(env)
4747
end
4848

49-
it 'should capture rails errors when ActionDispatch::ShowExceptions is enabled' do
50-
exception = build_exception
51-
env = {}
52-
53-
expect(Raven::Rack).to receive(:capture_exception).with(exception, env)
54-
55-
app = lambda do |e|
56-
e['action_dispatch.exception'] = exception
57-
[200, {}, ['okay']]
58-
end
59-
60-
stack = Raven::Rack.new(app)
61-
62-
stack.call(env)
63-
end
64-
6549
it 'should clear context after app is called' do
6650
Raven::Context.current.tags[:environment] = :test
6751

spec/raven/integrations/rails_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,31 @@
88
config.dsn = 'dummy://notaserver'
99
config.encoding = 'json'
1010
end
11-
11+
Rails.env = "production"
1212
TestApp.initialize!
1313
end
1414

15+
after(:each) do
16+
Raven.client.transport.events = []
17+
end
18+
1519
it "inserts middleware" do
1620
expect(TestApp.middleware).to include(Raven::Rack)
1721
end
1822

19-
pending "should capture exceptions" do
23+
it "should capture exceptions in production" do
2024
get "/exception"
2125
expect(response.status).to eq(500)
2226
expect(Raven.client.transport.events.size).to eq(1)
2327
end
28+
29+
it "should properly set the exception's URL" do
30+
get "/exception"
31+
32+
# TODO: dummy transport shouldn't even encode the event
33+
event = Raven.client.transport.events.first
34+
event = JSON.parse!(event[1])
35+
36+
expect(event['request']['url']).to eq("http://www.example.com/exception")
37+
end
2438
end

0 commit comments

Comments
 (0)