rollbar 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ **0.9.13**
4
+ - Add test for PUT params
5
+ - Parse json params when content-type is application/json
6
+ - Remove extraneous
7
+ - Remove redundant `GET` and `POST` keys from request payload (they're already included in `params`)
8
+
3
9
  **0.9.12**
4
10
  - Fix compatibility issue with Rails 4 / Ruby 2 (thanks [johnknott](https://github.com/johnknott))
5
11
 
@@ -11,20 +11,28 @@ module Rollbar
11
11
  end
12
12
 
13
13
  def extract_request_data_from_rack(env)
14
+ rack_req = Rack::Request.new(env)
15
+
14
16
  sensitive_params = sensitive_params_list(env)
15
17
  request_params = rollbar_request_params(env)
16
- cookies = rollbar_filtered_params(sensitive_params, rollbar_request_cookies(env))
17
- get_params = rollbar_filtered_params(sensitive_params, rollbar_get_params(env))
18
- post_params = rollbar_filtered_params(sensitive_params, rollbar_post_params(env))
18
+ get_params = rollbar_filtered_params(sensitive_params, rollbar_get_params(rack_req))
19
+ post_params = rollbar_filtered_params(sensitive_params, rollbar_post_params(rack_req))
20
+ cookies = rollbar_filtered_params(sensitive_params, rollbar_request_cookies(rack_req))
19
21
  session = rollbar_filtered_params(sensitive_params, env['rack.session.options'])
20
-
22
+
23
+ params = get_params.merge(post_params).merge(request_params)
24
+
25
+ # parse any json params
26
+ if env['CONTENT_TYPE'] =~ %r{application/json}i
27
+ json_params = JSON.parse(env['rack.input'].read) rescue {}
28
+ params = params.merge(json_params)
29
+ end
30
+
21
31
  {
22
- :params => get_params.merge(post_params).merge(request_params),
32
+ :params => params,
23
33
  :url => rollbar_url(env),
24
34
  :user_ip => rollbar_user_ip(env),
25
35
  :headers => rollbar_headers(env),
26
- :GET => get_params,
27
- :POST => post_params,
28
36
  :cookies => cookies,
29
37
  :session => session,
30
38
  :method => rollbar_request_method(env)
@@ -68,28 +76,24 @@ module Rollbar
68
76
  }
69
77
  end
70
78
 
71
- def rollbar_get_params(env)
72
- rack_request(env).GET
79
+ def rollbar_get_params(rack_req)
80
+ rack_req.GET
73
81
  rescue
74
82
  {}
75
83
  end
76
84
 
77
- def rollbar_post_params(env)
78
- rack_request(env).POST
85
+ def rollbar_post_params(rack_req)
86
+ rack_req.POST
79
87
  rescue
80
88
  {}
81
89
  end
82
-
83
- def rollbar_request_cookies(env)
84
- rack_request(env).cookie
90
+
91
+ def rollbar_request_cookies(rack_req)
92
+ rack_req.cookies
85
93
  rescue
86
94
  {}
87
95
  end
88
96
 
89
- def rack_request(env)
90
- @rack_request ||= Rack::Request.new(env)
91
- end
92
-
93
97
  def rollbar_filtered_params(sensitive_params, params)
94
98
  if params.nil?
95
99
  {}
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "0.9.12"
2
+ VERSION = "0.9.13"
3
3
  end
@@ -36,7 +36,6 @@ describe HomeController do
36
36
  data.should have_key(:url)
37
37
  data.should have_key(:user_ip)
38
38
  data.should have_key(:headers)
39
- data.should have_key(:GET)
40
39
  data.should have_key(:session)
41
40
  data.should have_key(:method)
42
41
  end
@@ -178,13 +177,32 @@ describe HomeController do
178
177
  end
179
178
  end
180
179
 
181
- describe "GET 'report_exception'" do
182
- it "should raise a NameError and report an exception" do
180
+ describe "'report_exception'", :type => "request" do
181
+ it "should raise a NameError and report an exception after a GET" do
183
182
  logger_mock.should_receive(:info).with('[Rollbar] Success')
184
183
 
185
184
  get 'report_exception'
186
185
  response.should be_success
187
186
  end
187
+
188
+ it "should raise a NameError and have PUT params in the reported exception" do
189
+ logger_mock.should_receive(:info).with('[Rollbar] Success')
190
+
191
+ put 'report_exception', :putparam => "putval"
192
+
193
+ Rollbar.last_report.should_not be_nil
194
+ Rollbar.last_report[:request][:params]["putparam"].should == "putval"
195
+ end
196
+
197
+ it "should raise a NameError and have JSON POST params" do
198
+ logger_mock.should_receive(:info).with('[Rollbar] Success')
199
+
200
+ params = {:jsonparam => 'jsonval'}.to_json
201
+ post 'report_exception', params, {'CONTENT_TYPE' => 'application/json'}
202
+
203
+ Rollbar.last_report.should_not be_nil
204
+ Rollbar.last_report[:request][:params]['jsonparam'].should == 'jsonval'
205
+ end
188
206
  end
189
207
 
190
208
  after(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-17 00:00:00.000000000 Z
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json