rollbar 0.12.13 → 0.12.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 076a6f8cb5fa3a2aa429329b23d38d9ef039bbb9
4
- data.tar.gz: fc8e676b598d4f2a3cd1f0f3ff6d7cc2eed6b88f
3
+ metadata.gz: 2e43cb0fee10ec04426c636b011a4f932d8f5a18
4
+ data.tar.gz: 8a9b636c79acd266d4f3fa313f07734ef160454e
5
5
  SHA512:
6
- metadata.gz: dcc4006b631c792b9867874e11374e4f68a303b93e861a99e525a9d0a5418149baf768f2411ca1b76d4ad0234283a4b049bfa965839929b9b7802d9f38010434
7
- data.tar.gz: 28174b6dfc0d3d69941de4e3bbcd3557c3672b67567e98144788e2285111c96dd0db188879118739b1c353a02efad653115b4c578891a51859ced5a5411918c9
6
+ metadata.gz: b641639ed666ddae670daefe34edf7d44ec6b8a9b5fa8db45bb58650c07a5c9807af04409b4e81d68facc0eaad3f353b3fcf24420444fef0df0df74bec89f972
7
+ data.tar.gz: 77ac64ab273cef507da4675c906ddaf3f9eb126714250f47ba7ac0d634cae80c2400c350d6022901abd2a01fd39925c2dfda6a4618b5309f88fff649e9753d09
data/Appraisals CHANGED
@@ -12,5 +12,4 @@ end
12
12
 
13
13
  appraise "rails40" do
14
14
  gem "rails", "4.0.0"
15
- gem "protected_attributes"
16
15
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ **0.12.14**
4
+ - Added ability to scrub request headers
5
+ - Added flag to disable reporting of Delayed::Job job data when handling uncaught exceptions that happen in jobs
6
+ - New `report_message_with_request` that allows reporting request and person data, similar to `report_exception`
7
+ - Changed various exception handlers to catch `Exception` subclasses instead of only `StandardError`s
8
+ - Added Capistrano 3 support
9
+
3
10
  **0.12.13**
4
11
  - Add a little more debugging information for 'payload too large' errors
5
12
  - Pushing new gem to fix errant 32kb size limit in the rubygems copy of 0.12.12
data/README.md CHANGED
@@ -116,7 +116,11 @@ Rollbar.report_message("Unexpected input", "warning")
116
116
  Rollbar.report_message("Login successful")
117
117
 
118
118
  # can also include additional data as a hash in the final param. :body is reserved.
119
- Rollbar.report_message("Login successful", "info", :user => @user)
119
+ Rollbar.report_message("Login successful", "info", :username => @username)
120
+
121
+ # pass request and person data
122
+ Rollbar.report_message_with_request("Settings saved", "debug", rollbar_request_data,
123
+ rollbar_person_data, :account_id => account.id)
120
124
  ```
121
125
 
122
126
  ## Data sanitization (scrubbing)
@@ -131,6 +135,10 @@ By default, the notifier will "scrub" the following fields from requests before
131
135
  - ```:password_confirmation```
132
136
  - ```:secret_token```
133
137
 
138
+ And the following http header
139
+
140
+ - ```"Authorization"```
141
+
134
142
  If a request contains one of these fields, the value will be replaced with a ```"*"``` before being sent.
135
143
 
136
144
  Additional fields can be scrubbed by updating ```Rollbar.configuration.scrub_fields```:
@@ -140,6 +148,14 @@ Additional fields can be scrubbed by updating ```Rollbar.configuration.scrub_fie
140
148
  Rollbar.configuration.scrub_fields |= [:user_password]
141
149
  ```
142
150
 
151
+ And ```Rollbar.configuration.scrub_headers```:
152
+
153
+ ```ruby
154
+ # scrub out the "X-Access-Token" http header
155
+ Rollbar.configuration.scrub_headers |= ["X-Access-Token"]
156
+ ```
157
+
158
+
143
159
  ## Person tracking
144
160
 
145
161
  Rollbar will send information about the current user (called a "person" in Rollbar parlance) along with each error report, when available. This works by calling the ```current_user``` controller method. The return value should be an object with an ```id``` method and, optionally, ```username``` and ```email``` methods.
@@ -198,6 +214,24 @@ Rollbar.silenced {
198
214
  }
199
215
  ```
200
216
 
217
+ ## Delayed::Job integration
218
+
219
+ If `delayed_job` is defined, Rollbar will automatically install a handler that reports any uncaught exceptions that occur in jobs.
220
+
221
+ By default, the job's data will be included in the report. If you want to disable this functionality to prevent sensitive data from possibly being sent, use the following configuration option:
222
+
223
+ ```ruby
224
+ config.report_dj_data = false # default is true
225
+ ```
226
+
227
+ You can also change the threshold of job retries that must occur before a job is reported to Rollbar:
228
+
229
+ ```ruby
230
+ config.dj_threshold = 2 # default is 0
231
+ ```
232
+
233
+
234
+
201
235
  ## Asynchronous reporting
202
236
 
203
237
  By default, all messages are reported synchronously. You can enable asynchronous reporting with [girl_friday](https://github.com/mperham/girl_friday) or [sucker_punch](https://github.com/brandonhilkert/sucker_punch) or [Sidekiq](https://github.com/mperham/sidekiq).
@@ -272,6 +306,23 @@ For this to work, you'll also need to set up rollbar-agent--see its docs for det
272
306
 
273
307
  ## Deploy Tracking with Capistrano
274
308
 
309
+ ### Capistrano 3
310
+
311
+ Add to your `Capfile`:
312
+
313
+ ```ruby
314
+ require 'rollbar/capistrano3'
315
+ ```
316
+
317
+ And then, to your `deploy.rb`:
318
+
319
+ ```ruby
320
+ set :rollbar_token, 'POST_SERVER_ITEM_ACCESS_TOKEN'
321
+ set :rollbar_env, Proc.new { fetch :stage }
322
+ ```
323
+
324
+ ### Capistrano 2
325
+
275
326
  Add the following to ```deploy.rb```:
276
327
 
277
328
  ```ruby
data/THANKS.md CHANGED
@@ -6,6 +6,8 @@ Huge thanks to the following contributors (by github username). For the most up-
6
6
  - [arr-ee](https://github.com/arr-ee)
7
7
  - [awmichel](https://github.com/awmichel)
8
8
  - [bradx3](https://github.com/bradx3)
9
+ - [chrisb](https://github.com/chrisb)
10
+ - [derekrockwell](https://github.com/derekrockwell)
9
11
  - [dimko](https://github.com/dimko)
10
12
  - [dlackty](https://github.com/dlackty)
11
13
  - [fabsays](https://github.com/fabsays)
@@ -17,6 +19,7 @@ Huge thanks to the following contributors (by github username). For the most up-
17
19
  - [juggler](https://github.com/juggler)
18
20
  - [kavu](https://github.com/kavu)
19
21
  - [magnolia-fan](https://github.com/magnolia-fan)
22
+ - [mauricio](https://github.com/mauricio)
20
23
  - [miloops](https://github.com/miloops)
21
24
  - [mipearson](https://github.com/mipearson)
22
25
  - [petergoldstein](https://github.com/petergoldstein)
@@ -6,13 +6,11 @@ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
6
6
  gem "jruby-openssl", :platform=>:jruby
7
7
  gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "appraisal"
9
-
10
- gem 'rubysl', '~> 2.0', :platform => :rbx
11
- gem 'racc', :platform => :rbx
12
- gem 'minitest', :platform => :rbx
13
- gem 'rubysl-test-unit', :platform => :rbx
14
- gem 'rubinius-developer_tools', :platform => :rbx
15
-
9
+ gem "rubysl", "~> 2.0", :platform=>:rbx
10
+ gem "racc", :platform=>:rbx
11
+ gem "minitest", :platform=>:rbx
12
+ gem "rubysl-test-unit", :platform=>:rbx
13
+ gem "rubinius-developer_tools", :platform=>:rbx
16
14
  gem "rails", "3.0.20"
17
15
 
18
16
  gemspec :path=>"../"
@@ -6,13 +6,11 @@ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
6
6
  gem "jruby-openssl", :platform=>:jruby
7
7
  gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "appraisal"
9
-
10
- gem 'rubysl', '~> 2.0', :platform => :rbx
11
- gem 'racc', :platform => :rbx
12
- gem 'minitest', :platform => :rbx
13
- gem 'rubysl-test-unit', :platform => :rbx
14
- gem 'rubinius-developer_tools', :platform => :rbx
15
-
9
+ gem "rubysl", "~> 2.0", :platform=>:rbx
10
+ gem "racc", :platform=>:rbx
11
+ gem "minitest", :platform=>:rbx
12
+ gem "rubysl-test-unit", :platform=>:rbx
13
+ gem "rubinius-developer_tools", :platform=>:rbx
16
14
  gem "rails", "3.1.12"
17
15
 
18
16
  gemspec :path=>"../"
@@ -6,13 +6,11 @@ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
6
6
  gem "jruby-openssl", :platform=>:jruby
7
7
  gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "appraisal"
9
-
10
- gem 'rubysl', '~> 2.0', :platform => :rbx
11
- gem 'racc', :platform => :rbx
12
- gem 'minitest', :platform => :rbx
13
- gem 'rubysl-test-unit', :platform => :rbx
14
- gem 'rubinius-developer_tools', :platform => :rbx
15
-
9
+ gem "rubysl", "~> 2.0", :platform=>:rbx
10
+ gem "racc", :platform=>:rbx
11
+ gem "minitest", :platform=>:rbx
12
+ gem "rubysl-test-unit", :platform=>:rbx
13
+ gem "rubinius-developer_tools", :platform=>:rbx
16
14
  gem "rails", "3.2.12"
17
15
 
18
16
  gemspec :path=>"../"
@@ -6,14 +6,11 @@ gem "sqlite3", :platform=>[:ruby, :mswin, :mingw]
6
6
  gem "jruby-openssl", :platform=>:jruby
7
7
  gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "appraisal"
9
+ gem "rubysl", "~> 2.0", :platform=>:rbx
10
+ gem "racc", :platform=>:rbx
11
+ gem "minitest", :platform=>:rbx
12
+ gem "rubysl-test-unit", :platform=>:rbx
13
+ gem "rubinius-developer_tools", :platform=>:rbx
9
14
  gem "rails", "4.0.0"
10
15
 
11
- gem 'rubysl', '~> 2.0', :platform => :rbx
12
- gem 'racc', :platform => :rbx
13
- gem 'minitest', :platform => :rbx
14
- gem 'rubysl-test-unit', :platform => :rbx
15
- gem 'rubinius-developer_tools', :platform => :rbx
16
-
17
- gem "protected_attributes"
18
-
19
16
  gemspec :path=>"../"
data/lib/rollbar.rb CHANGED
@@ -86,20 +86,8 @@ module Rollbar
86
86
  return 'ignored' if ignored?(exception)
87
87
 
88
88
  data = exception_data(exception, level ? level : filtered_level(exception))
89
- if request_data
90
- if request_data[:route]
91
- route = request_data[:route]
92
-
93
- # make sure route is a hash built by RequestDataExtractor in rails apps
94
- if route.is_a?(Hash) and not route.empty?
95
- data[:context] = "#{request_data[:route][:controller]}" + '#' + "#{request_data[:route][:action]}"
96
- end
97
- end
98
-
99
- request_data[:env].reject!{|k, v| v.is_a?(IO) } if request_data[:env]
100
- data[:request] = request_data
101
-
102
- end
89
+
90
+ attach_request_data(data, request_data) if request_data
103
91
  data[:person] = person_data if person_data
104
92
 
105
93
  @last_report = data
@@ -128,6 +116,43 @@ module Rollbar
128
116
  return 'disabled' unless configuration.enabled
129
117
 
130
118
  data = message_data(message, level, extra_data)
119
+
120
+ @last_report = data
121
+
122
+ payload = build_payload(data)
123
+ schedule_payload(payload)
124
+ log_instance_link(data)
125
+ data
126
+ rescue => e
127
+ report_internal_error(e)
128
+ 'error'
129
+ end
130
+
131
+ # Reports an arbitrary message to Rollbar with request and person data
132
+ #
133
+ # @example
134
+ # Rollbar.report_message_with_request("User login failed", 'info', rollbar_request_data, rollbar_person_data, :foo => 'bar')
135
+ #
136
+ # @param message [String] The message body. This will be used to identify the message within
137
+ # Rollbar. For best results, avoid putting variables in the message body; pass them as
138
+ # `extra_data` instead.
139
+ # @param level [String] The level. One of: 'critical', 'error', 'warning', 'info', 'debug'
140
+ # @param request_data [Hash] Data describing the request. Should be the result of calling
141
+ # `rollbar_request_data`.
142
+ # @param person_data [Hash] Data describing the affected person. Should be the result of calling
143
+ # `rollbar_person_data`
144
+ # @param extra_data [Hash] Additional data to include alongside the body. Don't use 'body' as
145
+ # it is reserved.
146
+ def report_message_with_request(message, level = 'info', request_data = nil, person_data = nil, extra_data = {})
147
+ return 'disabled' unless configuration.enabled
148
+
149
+ data = message_data(message, level, extra_data)
150
+
151
+ attach_request_data(data, request_data) if request_data
152
+ data[:person] = person_data if person_data
153
+
154
+ @last_report = data
155
+
131
156
  payload = build_payload(data)
132
157
  schedule_payload(payload)
133
158
  log_instance_link(data)
@@ -165,6 +190,20 @@ module Rollbar
165
190
  end
166
191
 
167
192
  private
193
+
194
+ def attach_request_data(payload, request_data)
195
+ if request_data[:route]
196
+ route = request_data[:route]
197
+
198
+ # make sure route is a hash built by RequestDataExtractor in rails apps
199
+ if route.is_a?(Hash) and not route.empty?
200
+ payload[:context] = "#{request_data[:route][:controller]}" + '#' + "#{request_data[:route][:action]}"
201
+ end
202
+ end
203
+
204
+ request_data[:env].reject!{|k, v| v.is_a?(IO) } if request_data[:env]
205
+ payload[:request] = request_data
206
+ end
168
207
 
169
208
  def require_hooks()
170
209
  require 'rollbar/delayed_job' if defined?(Delayed) && defined?(Delayed::Plugins)
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/rollbar.cap", __FILE__)
@@ -9,6 +9,7 @@ module Rollbar
9
9
  attr_accessor :code_version
10
10
  attr_accessor :custom_data_method
11
11
  attr_accessor :default_logger
12
+ attr_accessor :dj_threshold
12
13
  attr_accessor :enabled
13
14
  attr_accessor :endpoint
14
15
  attr_accessor :environment
@@ -21,8 +22,10 @@ module Rollbar
21
22
  attr_accessor :person_id_method
22
23
  attr_accessor :person_username_method
23
24
  attr_accessor :person_email_method
25
+ attr_accessor :report_dj_data
24
26
  attr_accessor :root
25
27
  attr_accessor :scrub_fields
28
+ attr_accessor :scrub_headers
26
29
  attr_accessor :use_async
27
30
  attr_accessor :use_eventmachine
28
31
  attr_accessor :web_base
@@ -38,6 +41,7 @@ module Rollbar
38
41
  @code_version = nil
39
42
  @custom_data_method = nil
40
43
  @default_logger = lambda { Logger.new(STDERR) }
44
+ @dj_threshold = 0
41
45
  @enabled = nil # set to true when configure is called
42
46
  @endpoint = DEFAULT_ENDPOINT
43
47
  @environment = nil
@@ -53,8 +57,10 @@ module Rollbar
53
57
  @person_username_method = 'username'
54
58
  @person_email_method = 'email'
55
59
  @project_gems = []
60
+ @report_dj_data = true
56
61
  @scrub_fields = [:passwd, :password, :password_confirmation, :secret,
57
62
  :confirm_password, :password_confirmation, :secret_token]
63
+ @scrub_headers = ['Authorization']
58
64
  @use_async = false
59
65
  @use_eventmachine = false
60
66
  @web_base = DEFAULT_WEB_BASE
@@ -8,7 +8,10 @@ module Delayed
8
8
  begin
9
9
  block.call(job, *args)
10
10
  rescue Exception => e
11
- ::Rollbar.report_exception(e, job)
11
+ if job.attempts >= ::Rollbar.configuration.dj_threshold
12
+ data = ::Rollbar.configuration.report_dj_data ? job : nil
13
+ ::Rollbar.report_exception(e, data)
14
+ end
12
15
  raise e
13
16
  end
14
17
  end
@@ -6,7 +6,7 @@ module Rollbar
6
6
 
7
7
  def call_with_rollbar(env)
8
8
  call_without_rollbar(env)
9
- rescue => exception
9
+ rescue Exception => exception
10
10
  report_exception_to_rollbar(env, exception)
11
11
  raise exception
12
12
  end
@@ -6,7 +6,7 @@ module Rollbar
6
6
 
7
7
  def env_for_with_rollbar(path, env)
8
8
  env_for_without_rollbar(path, env)
9
- rescue => exception
9
+ rescue Exception => exception
10
10
  report_exception_to_rollbar(env, exception)
11
11
  raise exception
12
12
  end
@@ -6,7 +6,7 @@ module Rollbar
6
6
 
7
7
  def render_exception_with_rollbar(env, exception)
8
8
  key = 'action_dispatch.show_detailed_exceptions'
9
-
9
+
10
10
  # don't report production exceptions here as it is done below
11
11
  # in call_with_rollbar() when show_detailed_exception is false
12
12
  if not env.has_key?(key) or env[key]
@@ -14,10 +14,10 @@ module Rollbar
14
14
  end
15
15
  render_exception_without_rollbar(env, exception)
16
16
  end
17
-
17
+
18
18
  def call_with_rollbar(env)
19
19
  call_without_rollbar(env)
20
- rescue => exception
20
+ rescue Exception => exception
21
21
  # won't reach here if show_detailed_exceptions is true
22
22
  report_exception_to_rollbar(env, exception)
23
23
  raise exception
@@ -50,9 +50,10 @@ module Rollbar
50
50
  def rollbar_headers(env)
51
51
  env.keys.grep(/^HTTP_/).map do |header|
52
52
  name = header.gsub(/^HTTP_/, '').split('_').map(&:capitalize).join('-')
53
- # exclude cookies - we already include a parsed version as request_data[:cookies]
54
53
  if name == 'Cookie'
55
- {}
54
+ {}
55
+ elsif sensitive_headers_list.include?(name)
56
+ { name => rollbar_scrubbed(env[header]) }
56
57
  else
57
58
  { name => env[header] }
58
59
  end
@@ -123,7 +124,7 @@ module Rollbar
123
124
  else
124
125
  params.to_hash.inject({}) do |result, (key, value)|
125
126
  if sensitive_params.include?(key.to_sym)
126
- result[key] = '*' * (value.length rescue 8)
127
+ result[key] = rollbar_scrubbed(value)
127
128
  elsif value.is_a?(Hash)
128
129
  result[key] = rollbar_filtered_params(sensitive_params, value)
129
130
  elsif ATTACHMENT_CLASSES.include?(value.class.name)
@@ -143,5 +144,14 @@ module Rollbar
143
144
  def sensitive_params_list(env)
144
145
  Rollbar.configuration.scrub_fields |= Array(env['action_dispatch.parameter_filter'])
145
146
  end
147
+
148
+ def sensitive_headers_list
149
+ Rollbar.configuration.scrub_headers |= []
150
+ end
151
+
152
+ def rollbar_scrubbed(value)
153
+ '*' * (value.length rescue 8)
154
+ end
155
+
146
156
  end
147
157
  end
@@ -5,7 +5,7 @@ module Rollbar
5
5
  def call(worker, msg, queue)
6
6
  begin
7
7
  yield
8
- rescue => e
8
+ rescue Exception => e
9
9
  msg.delete('backtrace')
10
10
  msg.delete('error_backtrace')
11
11
  msg.delete('error_message')
@@ -0,0 +1,38 @@
1
+ require 'net/http'
2
+ require 'rubygems'
3
+ require 'json'
4
+
5
+ namespace :rollbar do
6
+
7
+ desc 'Send the deployment notification to Rollbar.'
8
+ task :deploy do
9
+ uri = URI.parse 'https://api.rollbar.com/api/1/deploy/'
10
+ params = {
11
+ :local_username => fetch(:rollbar_user),
12
+ :access_token => fetch(:rollbar_token),
13
+ :environment => fetch(:rollbar_env),
14
+ :revision => fetch(:current_revision) }
15
+
16
+ request = Net::HTTP::Post.new(uri.request_uri)
17
+ request.body = JSON.dump(params)
18
+
19
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
20
+ http.request(request)
21
+ end
22
+
23
+ # this is not the right way to output to capistrano's log..
24
+ puts 'Rollbar notification complete.'
25
+ end
26
+ end
27
+
28
+ namespace :deploy do
29
+ after 'deploy:finished', 'rollbar:deploy'
30
+ end
31
+
32
+ namespace :load do
33
+ task :defaults do
34
+ set :rollbar_user, Proc.new { ENV['USER'] || ENV['USERNAME'] }
35
+ set :rollbar_env, Proc.new { fetch :rails_env, 'production' }
36
+ set :rollbar_token, Proc.new { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" }
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "0.12.13"
2
+ VERSION = "0.12.14"
3
3
  end
@@ -153,6 +153,42 @@ describe HomeController do
153
153
  end
154
154
  end
155
155
 
156
+ context 'rollbar_scrub_headers' do
157
+
158
+ it 'should filter authentication by default' do
159
+ headers = {
160
+ 'HTTP_AUTHORIZATION' => 'some-user',
161
+ 'HTTP_USER_AGENT' => 'spec'
162
+ }
163
+
164
+ filtered = controller.send( :rollbar_headers, headers )
165
+ filtered.should == {
166
+ "Authorization" => "*********",
167
+ "User-Agent" => "spec"
168
+ }
169
+ end
170
+
171
+ it 'should filter custom headers' do
172
+ Rollbar.configure do |config|
173
+ config.scrub_headers = ['Auth', 'Token']
174
+ end
175
+
176
+ headers = {
177
+ 'HTTP_AUTH' => 'auth-value',
178
+ 'HTTP_TOKEN' => 'token-value',
179
+ 'HTTP_CONTENT_TYPE' => 'text/html'
180
+ }
181
+
182
+ filtered = controller.send( :rollbar_headers, headers )
183
+ filtered.should == {
184
+ "Auth" => "**********",
185
+ "Token" => "***********",
186
+ "Content-Type" => "text/html"
187
+ }
188
+ end
189
+
190
+ end
191
+
156
192
  context "rollbar_request_url" do
157
193
  it "should build simple http urls" do
158
194
  req = controller.request
@@ -1,3 +1,7 @@
1
1
  class User < ActiveRecord::Base
2
- attr_accessible :username, :email, :password, :password_confirmation, :remember_me
2
+
3
+ if Rails::VERSION::MAJOR < 4
4
+ attr_accessible :username, :email, :password, :password_confirmation, :remember_me
5
+ end
6
+
3
7
  end
@@ -7,6 +7,6 @@
7
7
  # Mayor.create(name: 'Emanuel', city: cities.first)
8
8
  puts 'SETTING UP DEFAULT USER LOGIN'
9
9
  user = User.create! :username => 'user1', :email => 'user@example.com'
10
- puts 'New user created: ' << user.username
10
+ puts "New user created: #{user.username}"
11
11
  user2 = User.create! :username => 'user2', :email => 'user2@example.com'
12
- puts 'New user created: ' << user2.username
12
+ puts "New user created: #{user2.username}"
data/spec/rollbar_spec.rb CHANGED
@@ -324,6 +324,53 @@ describe Rollbar do
324
324
  end
325
325
  end
326
326
  end
327
+
328
+ context 'report_message_with_request' do
329
+ before(:each) do
330
+ configure
331
+ Rollbar.configure do |config|
332
+ config.logger = logger_mock
333
+ end
334
+ end
335
+
336
+ let(:logger_mock) { double("Rails.logger").as_null_object }
337
+ let(:user) { User.create(:email => 'email@example.com', :encrypted_password => '', :created_at => Time.now, :updated_at => Time.now) }
338
+
339
+ it 'should report simple messages' do
340
+ logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
341
+ logger_mock.should_receive(:info).with('[Rollbar] Success')
342
+ Rollbar.report_message_with_request("Test message")
343
+
344
+ Rollbar.last_report[:request].should be_nil
345
+ Rollbar.last_report[:person].should be_nil
346
+ end
347
+
348
+ it 'should report messages with request, person data and extra data' do
349
+ Rollbar.last_report = nil
350
+
351
+ logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
352
+ logger_mock.should_receive(:info).with('[Rollbar] Success')
353
+
354
+ request_data = {
355
+ :params => {:foo => 'bar'}
356
+ }
357
+
358
+ person_data = {
359
+ :id => 123,
360
+ :username => 'username'
361
+ }
362
+
363
+ extra_data = {
364
+ :extra_foo => 'extra_bar'
365
+ }
366
+
367
+ Rollbar.report_message_with_request("Test message", 'info', request_data, person_data, extra_data)
368
+
369
+ Rollbar.last_report[:request].should == request_data
370
+ Rollbar.last_report[:person].should == person_data
371
+ Rollbar.last_report[:body][:message][:extra_foo].should == 'extra_bar'
372
+ end
373
+ end
327
374
 
328
375
  context 'payload_destination' do
329
376
  before(:each) do
@@ -628,7 +675,7 @@ describe Rollbar do
628
675
  end
629
676
 
630
677
  it 'should send a failsafe message if the payload cannot be reduced enough' do
631
- logger_mock.should_receive(:error).with('[Rollbar] Sending failsafe response due to Could not send payload due to it being too large after truncating attempts.')
678
+ logger_mock.should_receive(:error).with(/Sending failsafe response due to Could not send payload due to it being too large after truncating attempts/)
632
679
  logger_mock.should_receive(:info).with('[Rollbar] Success')
633
680
 
634
681
  orig_max = Rollbar::MAX_PAYLOAD_SIZE
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.13
4
+ version: 0.12.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Rue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-07 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -149,6 +149,7 @@ files:
149
149
  - lib/rollbar/active_record_extension.rb
150
150
  - lib/rollbar/better_errors.rb
151
151
  - lib/rollbar/capistrano.rb
152
+ - lib/rollbar/capistrano3.rb
152
153
  - lib/rollbar/configuration.rb
153
154
  - lib/rollbar/delay/sidekiq.rb
154
155
  - lib/rollbar/delay/sucker_punch.rb
@@ -167,6 +168,7 @@ files:
167
168
  - lib/rollbar/rake_tasks.rb
168
169
  - lib/rollbar/request_data_extractor.rb
169
170
  - lib/rollbar/sidekiq.rb
171
+ - lib/rollbar/tasks/rollbar.cap
170
172
  - lib/rollbar/util.rb
171
173
  - lib/rollbar/version.rb
172
174
  - rollbar.gemspec