exception_notification 4.1.1 → 4.1.2

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: c6cd08f159f882bcc6c9edc00674e06c33b4f6e8
4
- data.tar.gz: 063db2017a4336e3b3471431ebd3c5d6cb1bd80a
3
+ metadata.gz: 4eb16cddf2508b34a6a2dde7228376c70ed01025
4
+ data.tar.gz: 667d58580ae06080b620d8938437155a6b9b0586
5
5
  SHA512:
6
- metadata.gz: 131d835c2f0375c1683d8eff1507bebf3b09cb9770ec3749ff18114789dd5152fbb75f50a7c511422ca174d55efb03ded293207f00ceb597287d8432fb2c0666
7
- data.tar.gz: ee3de090b851c0b2e04a3a69e8841068040390ec729b60398776913b2eb26e6283e6769046cbab4cb2339baa00b3484738c8a61ba9f942870ddef0a60f2311c8
6
+ metadata.gz: ca1acead20b24875e0cacdbf5574266bf4fa1d080a361eec0f877b794247773f1236854661698706e62fcdd18d47adeb2b64fb8d83c6d654d1cb43b941e32293
7
+ data.tar.gz: fac6c6c82dc3eebcb635e92fd16f011845d97bcdd4ad080f3acdfc4ef2e65284d9496e027f3cbc5f1b4c4d445cc244162e0bfbfb1d3d8909cbc4fd5bd5ad73e3
data/Appraisals CHANGED
@@ -1,11 +1,3 @@
1
- appraise "rails3_1" do
2
- gem 'rails', '~> 3.1.0'
3
- end
4
-
5
- appraise "rails3_2" do
6
- gem 'rails', '~> 3.2.0'
7
- end
8
-
9
1
  appraise "rails4_0" do
10
2
  gem 'rails', '4.0.5'
11
3
  end
@@ -13,3 +5,7 @@ end
13
5
  appraise "rails4_1" do
14
6
  gem 'rails', '~> 4.1.1'
15
7
  end
8
+
9
+ appraise "rails4_2" do
10
+ gem 'rails', '~> 4.2.0'
11
+ end
@@ -1,3 +1,7 @@
1
+ == 4.1.2
2
+ * enhancements
3
+ * Change format of Slack notifications (by @eldano)
4
+
1
5
  == 4.1.1
2
6
 
3
7
  * bug fixes
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Travis](https://api.travis-ci.org/smartinez87/exception_notification.png)](http://travis-ci.org/smartinez87/exception_notification)
5
5
  [![Coverage Status](https://coveralls.io/repos/smartinez87/exception_notification/badge.png?branch=master)](https://coveralls.io/r/smartinez87/exception_notification)
6
6
  [![Code Climate](https://codeclimate.com/github/smartinez87/exception_notification.png)](https://codeclimate.com/github/smartinez87/exception_notification)
7
- ![project status](http://stillmaintained.com/smartinez87/exception_notification.png)
8
7
 
9
8
  **THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF EXCEPTION NOTIFICATION, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.**
10
9
 
@@ -276,6 +275,13 @@ A complete list of `smtp_settings` options can be found in the [ActionMailer Con
276
275
  The parent mailer which ExceptionNotification mailer inherit from.
277
276
 
278
277
 
278
+ ##### deliver_with
279
+
280
+ *Symbol, default: :deliver_now
281
+
282
+ The method name to send emalis using ActionMailer.
283
+
284
+
279
285
  ### Campfire notifier
280
286
 
281
287
  This notifier sends notifications to your Campfire room.
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'exception_notification'
3
- s.version = '4.1.1'
3
+ s.version = '4.1.2'
4
4
  s.authors = ["Jamis Buck", "Josh Peek"]
5
- s.date = %q{2015-06-09}
5
+ s.date = %q{2015-12-04}
6
6
  s.summary = "Exception notification for Rails apps"
7
7
  s.homepage = "http://smartinez87.github.com/exception_notification"
8
8
  s.email = "smartinez87@gmail.com"
9
9
  s.license = "MIT"
10
10
 
11
- s.required_ruby_version = '>= 1.9.3'
11
+ s.required_ruby_version = '>= 2.0'
12
12
  s.required_rubygems_version = '>= 1.8.11'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
@@ -16,17 +16,18 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- test`.split("\n")
17
17
  s.require_path = 'lib'
18
18
 
19
- s.add_dependency("actionmailer", ">= 3.0.4")
20
- s.add_dependency("activesupport", ">= 3.0.4")
19
+ s.add_dependency("actionmailer", "~> 4.0")
20
+ s.add_dependency("activesupport", "~> 4.0")
21
21
 
22
- s.add_development_dependency "rails", ">= 3.0.4"
22
+ s.add_development_dependency "rails", "~> 4.0"
23
23
  s.add_development_dependency "resque", "~> 1.2.0"
24
- s.add_development_dependency "sidekiq", "~> 3.0"
24
+ # Sidekiq 3.2.2 does not support Ruby 1.9.
25
+ s.add_development_dependency "sidekiq", "~> 3.0.0", "< 3.2.2"
25
26
  s.add_development_dependency "tinder", "~> 1.8"
26
27
  s.add_development_dependency "httparty", "~> 0.10.2"
27
28
  s.add_development_dependency "mocha", ">= 0.13.0"
28
29
  s.add_development_dependency "sqlite3", ">= 1.3.4"
29
- s.add_development_dependency "coveralls", "~> 0.6.5"
30
+ s.add_development_dependency "coveralls", "~> 0.8.2"
30
31
  s.add_development_dependency "appraisal", "~> 1.0.0"
31
32
  s.add_development_dependency "hipchat", ">= 1.0.0"
32
33
  s.add_development_dependency "carrier-pigeon", ">= 0.7.0"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 3.1.0"
5
+ gem "rails", "~> 4.2.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -17,7 +17,11 @@ module ExceptionNotifier
17
17
  end
18
18
 
19
19
  def call(exception, options={})
20
- @room.paste "A new exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'" if active?
20
+ if active?
21
+ message = "A new exception occurred: '#{exception.message}'"
22
+ message += " on '#{exception.backtrace.first}'" if exception.backtrace
23
+ @room.paste message message
24
+ end
21
25
  end
22
26
 
23
27
  private
@@ -7,7 +7,7 @@ module ExceptionNotifier
7
7
  class EmailNotifier < Struct.new(:sender_address, :exception_recipients,
8
8
  :email_prefix, :email_format, :sections, :background_sections,
9
9
  :verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
10
- :email_headers, :mailer_parent, :template_path)
10
+ :email_headers, :mailer_parent, :template_path, :deliver_with)
11
11
 
12
12
  module Mailer
13
13
  class MissingController
@@ -88,11 +88,11 @@ module ExceptionNotifier
88
88
  name = @env.nil? ? 'background_exception_notification' : 'exception_notification'
89
89
 
90
90
  headers = {
91
- :delivery_method => @options[:delivery_method],
92
- :to => @options[:exception_recipients],
93
- :from => @options[:sender_address],
94
- :subject => subject,
95
- :template_name => name
91
+ :delivery_method => @options[:delivery_method],
92
+ :to => @options[:exception_recipients],
93
+ :from => @options[:sender_address],
94
+ :subject => subject,
95
+ :template_name => name
96
96
  }.merge(@options[:email_headers])
97
97
 
98
98
  mail = mail(headers) do |format|
@@ -123,7 +123,7 @@ module ExceptionNotifier
123
123
  :sender_address, :exception_recipients,
124
124
  :email_prefix, :email_format, :sections, :background_sections,
125
125
  :verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
126
- :email_headers, :mailer_parent, :template_path))
126
+ :email_headers, :mailer_parent, :template_path, :deliver_with))
127
127
  end
128
128
 
129
129
  def options
@@ -140,12 +140,7 @@ module ExceptionNotifier
140
140
  end
141
141
 
142
142
  def call(exception, options={})
143
- message = create_email(exception, options)
144
- if message.respond_to?(:deliver_now)
145
- message.deliver_now
146
- else
147
- message.deliver
148
- end
143
+ create_email(exception, options).send(deliver_with)
149
144
  end
150
145
 
151
146
  def create_email(exception, options={})
@@ -172,7 +167,8 @@ module ExceptionNotifier
172
167
  :mailer_settings => nil,
173
168
  :email_headers => {},
174
169
  :mailer_parent => 'ActionMailer::Base',
175
- :template_path => 'exception_notifier'
170
+ :template_path => 'exception_notifier',
171
+ :deliver_with => :deliver_now
176
172
  }
177
173
  end
178
174
 
@@ -15,7 +15,9 @@ module ExceptionNotifier
15
15
  @from = options.delete(:from) || 'Exception'
16
16
  @room = HipChat::Client.new(api_token, opts)[room_name]
17
17
  @message_template = options.delete(:message_template) || ->(exception) {
18
- "A new exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'"
18
+ msg = "A new exception occurred: '#{exception.message}'"
19
+ msg += " on '#{exception.backtrace.first}'" if exception.backtrace
20
+ msg
19
21
  }
20
22
  @message_options = options
21
23
  @message_options[:color] ||= 'red'
@@ -6,7 +6,8 @@ module ExceptionNotifier
6
6
  end
7
7
 
8
8
  def call(exception, options={})
9
- message = "'#{exception.message}' on '#{exception.backtrace.first}'"
9
+ message = "'#{exception.message}'"
10
+ message += " on '#{exception.backtrace.first}'" if exception.backtrace
10
11
  send_message([*@config.prefix, *message].join(' ')) if active?
11
12
  end
12
13
 
@@ -42,4 +43,4 @@ module ExceptionNotifier
42
43
  false
43
44
  end
44
45
  end
45
- end
46
+ end
@@ -17,12 +17,28 @@ module ExceptionNotifier
17
17
  end
18
18
 
19
19
  def call(exception, options={})
20
- message = "An exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'"
20
+ env = options[:env] || {}
21
+ title = "#{env['REQUEST_METHOD']} <#{env['REQUEST_URI']}>"
22
+ data = (env['exception_notifier.exception_data'] || {}).merge(options[:data] || {})
23
+ text = "*An exception occurred while doing*: `#{title}`\n"
21
24
 
22
- message = enrich_message_with_data(message, options)
23
- message = enrich_message_with_backtrace(message, exception)
25
+ clean_message = exception.message.gsub("`", "'")
26
+ fields = [ { title: 'Exception', value: clean_message} ]
24
27
 
25
- @notifier.ping(message, @message_opts) if valid?
28
+ if exception.backtrace
29
+ formatted_backtrace = "```#{exception.backtrace.first(5).join("\n")}```"
30
+ fields.push({ title: 'Backtrace', value: formatted_backtrace })
31
+ end
32
+
33
+ unless data.empty?
34
+ deep_reject(data, @ignore_data_if) if @ignore_data_if.is_a?(Proc)
35
+ data_string = data.map{|k,v| "#{k}: #{v}"}.join("\n")
36
+ fields.push({ title: 'Data', value: "```#{data_string}```" })
37
+ end
38
+
39
+ attchs = [color: 'danger', text: text, fields: fields, mrkdwn_in: %w(text fields)]
40
+
41
+ @notifier.ping '', @message_opts.merge(attachments: attchs) if valid?
26
42
  end
27
43
 
28
44
  protected
@@ -31,35 +47,17 @@ module ExceptionNotifier
31
47
  !@notifier.nil?
32
48
  end
33
49
 
34
- def enrich_message_with_data(message, options)
35
- def deep_reject(hash, block)
36
- hash.each do |k, v|
37
- if v.is_a?(Hash)
38
- deep_reject(v, block)
39
- end
40
-
41
- if block.call(k, v)
42
- hash.delete(k)
43
- end
50
+ def deep_reject(hash, block)
51
+ hash.each do |k, v|
52
+ if v.is_a?(Hash)
53
+ deep_reject(v, block)
44
54
  end
45
- end
46
-
47
- data = ((options[:env] || {})['exception_notifier.exception_data'] || {}).merge(options[:data] || {})
48
- deep_reject(data, @ignore_data_if) if @ignore_data_if.is_a?(Proc)
49
- text = data.map{|k,v| "#{k}: #{v}"}.join(', ')
50
55
 
51
- if text.present?
52
- text = ['*Data:*', text].join("\n")
53
- [message, text].join("\n")
54
- else
55
- message
56
+ if block.call(k, v)
57
+ hash.delete(k)
58
+ end
56
59
  end
57
60
  end
58
61
 
59
- def enrich_message_with_backtrace(message, exception)
60
- backtrace = clean_backtrace(exception).first(10).join("\n")
61
- [message, ['*Backtrace:*', backtrace]].join("\n")
62
- end
63
-
64
62
  end
65
63
  end
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '4.0.0'
3
+ gem 'rails', '4.2.0'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -1,112 +1,130 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- exception_notification (4.1.0.rc1)
5
- actionmailer (>= 3.0.4)
6
- activesupport (>= 3.0.4)
4
+ exception_notification (4.1.1)
5
+ actionmailer (~> 4.0)
6
+ activesupport (~> 4.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (4.0.0)
12
- actionpack (= 4.0.0)
13
- mail (~> 2.5.3)
14
- actionpack (4.0.0)
15
- activesupport (= 4.0.0)
16
- builder (~> 3.1.0)
17
- erubis (~> 2.7.0)
18
- rack (~> 1.5.2)
11
+ actionmailer (4.2.0)
12
+ actionpack (= 4.2.0)
13
+ actionview (= 4.2.0)
14
+ activejob (= 4.2.0)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ rails-dom-testing (~> 1.0, >= 1.0.5)
17
+ actionpack (4.2.0)
18
+ actionview (= 4.2.0)
19
+ activesupport (= 4.2.0)
20
+ rack (~> 1.6.0)
19
21
  rack-test (~> 0.6.2)
20
- activemodel (4.0.0)
21
- activesupport (= 4.0.0)
22
- builder (~> 3.1.0)
23
- activerecord (4.0.0)
24
- activemodel (= 4.0.0)
25
- activerecord-deprecated_finders (~> 1.0.2)
26
- activesupport (= 4.0.0)
27
- arel (~> 4.0.0)
28
- activerecord-deprecated_finders (1.0.3)
29
- activesupport (4.0.0)
30
- i18n (~> 0.6, >= 0.6.4)
31
- minitest (~> 4.2)
32
- multi_json (~> 1.3)
33
- thread_safe (~> 0.1)
34
- tzinfo (~> 0.3.37)
35
- arel (4.0.0)
36
- atomic (1.1.10)
37
- builder (3.1.4)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
24
+ actionview (4.2.0)
25
+ activesupport (= 4.2.0)
26
+ builder (~> 3.1)
27
+ erubis (~> 2.7.0)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
30
+ activejob (4.2.0)
31
+ activesupport (= 4.2.0)
32
+ globalid (>= 0.3.0)
33
+ activemodel (4.2.0)
34
+ activesupport (= 4.2.0)
35
+ builder (~> 3.1)
36
+ activerecord (4.2.0)
37
+ activemodel (= 4.2.0)
38
+ activesupport (= 4.2.0)
39
+ arel (~> 6.0)
40
+ activesupport (4.2.0)
41
+ i18n (~> 0.7)
42
+ json (~> 1.7, >= 1.7.7)
43
+ minitest (~> 5.1)
44
+ thread_safe (~> 0.3, >= 0.3.4)
45
+ tzinfo (~> 1.1)
46
+ arel (6.0.3)
47
+ builder (3.2.2)
38
48
  erubis (2.7.0)
39
- eventmachine (1.0.3)
40
- faraday (0.8.7)
41
- multipart-post (~> 1.1)
42
- faraday_middleware (0.9.0)
43
- faraday (>= 0.7.4, < 0.9)
44
- hashie (1.2.0)
45
- hike (1.2.3)
49
+ eventmachine (1.0.8)
50
+ faraday (0.9.1)
51
+ multipart-post (>= 1.2, < 3)
52
+ faraday_middleware (0.10.0)
53
+ faraday (>= 0.7.4, < 0.10)
54
+ globalid (0.3.6)
55
+ activesupport (>= 4.1.0)
56
+ hashie (3.4.2)
46
57
  http_parser.rb (0.5.3)
47
- httparty (0.11.0)
48
- multi_json (~> 1.0)
58
+ httparty (0.13.5)
59
+ json (~> 1.8)
49
60
  multi_xml (>= 0.5.2)
50
- i18n (0.6.4)
51
- json (1.7.7)
52
- mail (2.5.4)
53
- mime-types (~> 1.16)
54
- treetop (~> 1.4.8)
55
- mime-types (1.23)
56
- minitest (4.7.5)
57
- multi_json (1.7.7)
58
- multi_xml (0.5.4)
59
- multipart-post (1.2.0)
60
- polyglot (0.3.3)
61
- rack (1.5.2)
62
- rack-test (0.6.2)
61
+ i18n (0.7.0)
62
+ json (1.8.3)
63
+ loofah (2.0.3)
64
+ nokogiri (>= 1.5.9)
65
+ mail (2.6.3)
66
+ mime-types (>= 1.16, < 3)
67
+ mime-types (2.6.1)
68
+ mini_portile (0.6.2)
69
+ minitest (5.8.0)
70
+ multi_json (1.11.2)
71
+ multi_xml (0.5.5)
72
+ multipart-post (2.0.0)
73
+ nokogiri (1.6.6.2)
74
+ mini_portile (~> 0.6.0)
75
+ rack (1.6.4)
76
+ rack-test (0.6.3)
63
77
  rack (>= 1.0)
64
- rails (4.0.0)
65
- actionmailer (= 4.0.0)
66
- actionpack (= 4.0.0)
67
- activerecord (= 4.0.0)
68
- activesupport (= 4.0.0)
78
+ rails (4.2.0)
79
+ actionmailer (= 4.2.0)
80
+ actionpack (= 4.2.0)
81
+ actionview (= 4.2.0)
82
+ activejob (= 4.2.0)
83
+ activemodel (= 4.2.0)
84
+ activerecord (= 4.2.0)
85
+ activesupport (= 4.2.0)
69
86
  bundler (>= 1.3.0, < 2.0)
70
- railties (= 4.0.0)
71
- sprockets-rails (~> 2.0.0)
72
- railties (4.0.0)
73
- actionpack (= 4.0.0)
74
- activesupport (= 4.0.0)
87
+ railties (= 4.2.0)
88
+ sprockets-rails
89
+ rails-deprecated_sanitizer (1.0.3)
90
+ activesupport (>= 4.2.0.alpha)
91
+ rails-dom-testing (1.0.7)
92
+ activesupport (>= 4.2.0.beta, < 5.0)
93
+ nokogiri (~> 1.6.0)
94
+ rails-deprecated_sanitizer (>= 1.0.1)
95
+ rails-html-sanitizer (1.0.2)
96
+ loofah (~> 2.0)
97
+ railties (4.2.0)
98
+ actionpack (= 4.2.0)
99
+ activesupport (= 4.2.0)
75
100
  rake (>= 0.8.7)
76
101
  thor (>= 0.18.1, < 2.0)
77
- rake (10.1.0)
102
+ rake (10.4.2)
78
103
  simple_oauth (0.1.9)
79
- sprockets (2.10.0)
80
- hike (~> 1.2)
81
- multi_json (~> 1.0)
104
+ sprockets (3.3.3)
82
105
  rack (~> 1.0)
83
- tilt (~> 1.1, != 1.3.0)
84
- sprockets-rails (2.0.0)
106
+ sprockets-rails (2.3.2)
85
107
  actionpack (>= 3.0)
86
108
  activesupport (>= 3.0)
87
- sprockets (~> 2.8)
88
- sqlite3 (1.3.7)
89
- thor (0.18.1)
90
- thread_safe (0.1.0)
91
- atomic
92
- tilt (1.4.1)
93
- tinder (1.9.2)
109
+ sprockets (>= 2.8, < 4.0)
110
+ sqlite3 (1.3.10)
111
+ thor (0.19.1)
112
+ thread_safe (0.3.5)
113
+ tinder (1.10.1)
94
114
  eventmachine (~> 1.0)
95
- faraday (~> 0.8)
115
+ faraday (~> 0.9.0)
96
116
  faraday_middleware (~> 0.9)
97
- hashie (~> 1.0)
98
- json (~> 1.7.5)
99
- mime-types (~> 1.19)
100
- multi_json (~> 1.5)
117
+ hashie (>= 1.0)
118
+ json (~> 1.8.0)
119
+ mime-types
120
+ multi_json (~> 1.7)
101
121
  twitter-stream (~> 0.1)
102
- treetop (1.4.14)
103
- polyglot
104
- polyglot (>= 0.3.1)
105
122
  twitter-stream (0.1.16)
106
123
  eventmachine (>= 0.12.8)
107
124
  http_parser.rb (~> 0.5.1)
108
125
  simple_oauth (~> 0.1.4)
109
- tzinfo (0.3.37)
126
+ tzinfo (1.2.2)
127
+ thread_safe (~> 0.1)
110
128
 
111
129
  PLATFORMS
112
130
  ruby
@@ -114,6 +132,6 @@ PLATFORMS
114
132
  DEPENDENCIES
115
133
  exception_notification!
116
134
  httparty
117
- rails (= 4.0.0)
135
+ rails (= 4.2.0)
118
136
  sqlite3
119
137
  tinder
@@ -1,6 +1,7 @@
1
1
  Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
+ config.eager_load = false
4
5
  # In the development environment your application's code is reloaded on
5
6
  # every request. This slows down response time but is perfect for development
6
7
  # since you don't have to restart the webserver when you make code changes.
@@ -1,6 +1,7 @@
1
1
  Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
+ config.eager_load = true
4
5
  # The production environment is meant for finished, "live" apps.
5
6
  # Code is not reloaded between requests
6
7
  config.cache_classes = true
@@ -1,6 +1,7 @@
1
1
  Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
+ config.eager_load = false
4
5
  # The test environment is used exclusively to run your application's
5
6
  # test suite. You never need to work with it otherwise. Remember that
6
7
  # your test database is "scratch space" for the test suite and is wiped
@@ -32,4 +33,6 @@ Dummy::Application.configure do
32
33
 
33
34
  # Print deprecation notices to the stderr
34
35
  config.active_support.deprecation = :stderr
36
+
37
+ config.active_support.test_order = :random
35
38
  end
@@ -5,3 +5,4 @@
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
7
  Dummy::Application.config.secret_token = 'cfdf538142b0b383e722e8e7ea839b8ce6c3dc94a57856b343a2d13be66f5b690a55c991cec6e98ed60ea9b7e58265af23cb40cbadee02f13f1c45c2625f482b'
8
+ Dummy::Application.config.secret_key_base = 'my new secret'
@@ -16,6 +16,18 @@ class CampfireNotifierTest < ActiveSupport::TestCase
16
16
  assert_includes notif[:message][:body], "/exception_notification/test/campfire_test.rb:45"
17
17
  end
18
18
 
19
+ test "should send campfire notification without backtrace info if properly configured" do
20
+ ExceptionNotifier::CampfireNotifier.stubs(:new).returns(Object.new)
21
+ campfire = ExceptionNotifier::CampfireNotifier.new({:subdomain => 'test', :token => 'test_token', :room_name => 'test_room'})
22
+ campfire.stubs(:call).returns(fake_notification_without_backtrace)
23
+ notif = campfire.call(fake_exception_without_backtrace)
24
+
25
+ assert !notif[:message].empty?
26
+ assert_equal notif[:message][:type], 'PasteMessage'
27
+ assert_includes notif[:message][:body], "A new exception occurred:"
28
+ assert_includes notif[:message][:body], "my custom error"
29
+ end
30
+
19
31
  test "should not send campfire notification if badly configured" do
20
32
  wrong_params = {:subdomain => 'test', :token => 'bad_token', :room_name => 'test_room'}
21
33
  Tinder::Campfire.stubs(:new).with('test', {:token => 'bad_token'}).returns(nil)
@@ -50,4 +62,15 @@ class CampfireNotifierTest < ActiveSupport::TestCase
50
62
  e
51
63
  end
52
64
  end
65
+
66
+ def fake_notification_without_backtrace
67
+ {:message => {:type => 'PasteMessage',
68
+ :body => "A new exception occurred: 'my custom error'"
69
+ }
70
+ }
71
+ end
72
+
73
+ def fake_exception_without_backtrace
74
+ StandardError.new('my custom error')
75
+ end
53
76
  end
@@ -149,4 +149,22 @@ class EmailNotifierTest < ActiveSupport::TestCase
149
149
  assert_equal @ignored_exception.class.inspect, "ActiveRecord::RecordNotFound"
150
150
  assert_nil @ignored_mail
151
151
  end
152
+
153
+ if defined?(Rails) && ('4.2'...'5.0').cover?(Rails.version)
154
+ test "should be able to specify ActionMailer::MessageDelivery method" do
155
+ email_notifier = ExceptionNotifier::EmailNotifier.new(
156
+ :email_prefix => '[Dummy ERROR] ',
157
+ :sender_address => %{"Dummy Notifier" <dummynotifier@example.com>},
158
+ :exception_recipients => %w{dummyexceptions@example.com},
159
+ :deliver_with => :deliver_now
160
+ )
161
+ # In Rails 4.2, it gives deprecation warning like "`#deliver` is
162
+ # deprecated and will be removed in Rails 5." when "#deliver" is
163
+ # used. If methods like "#deliver_now" is used, it should not
164
+ # give any warnings.
165
+ assert_silent do
166
+ email_notifier.call(@exception)
167
+ end
168
+ end
169
+ end
152
170
  end
@@ -16,6 +16,19 @@ class HipchatNotifierTest < ActiveSupport::TestCase
16
16
  hipchat.call(fake_exception)
17
17
  end
18
18
 
19
+ test "should send hipchat notification without backtrace info if properly configured" do
20
+ options = {
21
+ :api_token => 'good_token',
22
+ :room_name => 'room_name',
23
+ :color => 'yellow',
24
+ }
25
+
26
+ HipChat::Room.any_instance.expects(:send).with('Exception', fake_body_without_backtrace, { :color => 'yellow' })
27
+
28
+ hipchat = ExceptionNotifier::HipchatNotifier.new(options)
29
+ hipchat.call(fake_exception_without_backtrace)
30
+ end
31
+
19
32
  test "should allow custom from value if set" do
20
33
  options = {
21
34
  :api_token => 'good_token',
@@ -111,4 +124,12 @@ class HipchatNotifierTest < ActiveSupport::TestCase
111
124
  e
112
125
  end
113
126
  end
127
+
128
+ def fake_body_without_backtrace
129
+ "A new exception occurred: '#{fake_exception_without_backtrace.message}'"
130
+ end
131
+
132
+ def fake_exception_without_backtrace
133
+ StandardError.new('my custom error')
134
+ end
114
135
  end
@@ -16,6 +16,19 @@ class IrcNotifierTest < ActiveSupport::TestCase
16
16
  irc.call(fake_exception)
17
17
  end
18
18
 
19
+ test "should send irc notification without backtrace info if properly configured" do
20
+ options = {
21
+ :domain => 'irc.example.com'
22
+ }
23
+
24
+ CarrierPigeon.expects(:send).with(has_key(:uri)) do |v|
25
+ /my custom error/.match(v[:message])
26
+ end
27
+
28
+ irc = ExceptionNotifier::IrcNotifier.new(options)
29
+ irc.call(fake_exception_without_backtrace)
30
+ end
31
+
19
32
  test "should properly construct URI from constituent parts" do
20
33
  options = {
21
34
  :nick => 'BadNewsBot',
@@ -82,4 +95,8 @@ class IrcNotifierTest < ActiveSupport::TestCase
82
95
  e
83
96
  end
84
97
  end
98
+
99
+ def fake_exception_without_backtrace
100
+ StandardError.new('my custom error')
101
+ end
85
102
  end
@@ -14,19 +14,30 @@ class SlackNotifierTest < ActiveSupport::TestCase
14
14
  webhook_url: "http://slack.webhook.url"
15
15
  }
16
16
 
17
- Slack::Notifier.any_instance.expects(:ping).with(fake_notification, {})
17
+ Slack::Notifier.any_instance.expects(:ping).with('', fake_notification)
18
18
 
19
19
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
20
20
  slack_notifier.call(@exception)
21
21
  end
22
22
 
23
+ test "should send a slack notification without backtrace info if properly configured" do
24
+ options = {
25
+ webhook_url: "http://slack.webhook.url"
26
+ }
27
+
28
+ Slack::Notifier.any_instance.expects(:ping).with('', fake_notification(fake_exception_without_backtrace))
29
+
30
+ slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
31
+ slack_notifier.call(fake_exception_without_backtrace)
32
+ end
33
+
23
34
  test "should send the notification to the specified channel" do
24
35
  options = {
25
36
  webhook_url: "http://slack.webhook.url",
26
37
  channel: "channel"
27
38
  }
28
39
 
29
- Slack::Notifier.any_instance.expects(:ping).with(fake_notification, {})
40
+ Slack::Notifier.any_instance.expects(:ping).with('', fake_notification)
30
41
 
31
42
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
32
43
  slack_notifier.call(@exception)
@@ -40,7 +51,7 @@ class SlackNotifierTest < ActiveSupport::TestCase
40
51
  username: "username"
41
52
  }
42
53
 
43
- Slack::Notifier.any_instance.expects(:ping).with(fake_notification, {})
54
+ Slack::Notifier.any_instance.expects(:ping).with('', fake_notification)
44
55
 
45
56
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
46
57
  slack_notifier.call(@exception)
@@ -58,7 +69,7 @@ class SlackNotifierTest < ActiveSupport::TestCase
58
69
  }
59
70
  }
60
71
 
61
- Slack::Notifier.any_instance.expects(:ping).with(fake_notification, {icon_url: "icon"})
72
+ Slack::Notifier.any_instance.expects(:ping).with('', options[:additional_parameters].merge(fake_notification) )
62
73
 
63
74
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
64
75
  slack_notifier.call(@exception)
@@ -70,7 +81,7 @@ class SlackNotifierTest < ActiveSupport::TestCase
70
81
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
71
82
 
72
83
  assert_nil slack_notifier.notifier
73
- assert_nil slack_notifier.call(fake_exception)
84
+ assert_nil slack_notifier.call(@exception)
74
85
  end
75
86
 
76
87
  test "should pass along environment data" do
@@ -92,9 +103,9 @@ class SlackNotifierTest < ActiveSupport::TestCase
92
103
  }
93
104
  }
94
105
 
95
- expected_data_string = 'foo: bar, john: doe, user_id: 5'
106
+ expected_data_string = "foo: bar\njohn: doe\nuser_id: 5"
96
107
 
97
- Slack::Notifier.any_instance.expects(:ping).with(fake_notification(@exception, expected_data_string), {})
108
+ Slack::Notifier.any_instance.expects(:ping).with('', fake_notification(@exception, expected_data_string))
98
109
  slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
99
110
  slack_notifier.call(@exception, notification_options)
100
111
  end
@@ -109,9 +120,18 @@ class SlackNotifierTest < ActiveSupport::TestCase
109
120
  end
110
121
  end
111
122
 
123
+ def fake_exception_without_backtrace
124
+ StandardError.new('my custom error')
125
+ end
126
+
112
127
  def fake_notification(exception=@exception, data_string=nil)
113
- message = "An exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'\n"
114
- message += "*Data:*\n#{data_string}\n" unless data_string.nil?
115
- message += "*Backtrace:*\n" + exception.backtrace.join("\n")
128
+ text = "*An exception occurred while doing*: ` <>`\n"
129
+
130
+ fields = [ { title: 'Exception', value: exception.message} ]
131
+ fields.push({ title: 'Backtrace', value: "```backtrace line 1\nbacktrace line 2```" }) if exception.backtrace
132
+ fields.push({ title: 'Data', value: "```#{data_string}```" }) if data_string
133
+
134
+ { attachments: [ color: 'danger', text: text, fields: fields, mrkdwn_in: %w(text fields) ] }
116
135
  end
136
+
117
137
  end
@@ -15,3 +15,4 @@ require File.expand_path("../dummy/test/test_helper.rb", __FILE__)
15
15
  require "mocha/setup"
16
16
 
17
17
  Rails.backtrace_cleaner.remove_silencers!
18
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,50 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-09 00:00:00.000000000 Z
12
+ date: 2015-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.4
20
+ version: '4.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.4
27
+ version: '4.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.4
34
+ version: '4.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 3.0.4
41
+ version: '4.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 3.0.4
48
+ version: '4.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 3.0.4
55
+ version: '4.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: resque
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -73,14 +73,20 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '3.0'
76
+ version: 3.0.0
77
+ - - "<"
78
+ - !ruby/object:Gem::Version
79
+ version: 3.2.2
77
80
  type: :development
78
81
  prerelease: false
79
82
  version_requirements: !ruby/object:Gem::Requirement
80
83
  requirements:
81
84
  - - "~>"
82
85
  - !ruby/object:Gem::Version
83
- version: '3.0'
86
+ version: 3.0.0
87
+ - - "<"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.2.2
84
90
  - !ruby/object:Gem::Dependency
85
91
  name: tinder
86
92
  requirement: !ruby/object:Gem::Requirement
@@ -143,14 +149,14 @@ dependencies:
143
149
  requirements:
144
150
  - - "~>"
145
151
  - !ruby/object:Gem::Version
146
- version: 0.6.5
152
+ version: 0.8.2
147
153
  type: :development
148
154
  prerelease: false
149
155
  version_requirements: !ruby/object:Gem::Requirement
150
156
  requirements:
151
157
  - - "~>"
152
158
  - !ruby/object:Gem::Version
153
- version: 0.6.5
159
+ version: 0.8.2
154
160
  - !ruby/object:Gem::Dependency
155
161
  name: appraisal
156
162
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +223,6 @@ files:
217
223
  - CHANGELOG.rdoc
218
224
  - CONTRIBUTING.md
219
225
  - Gemfile
220
- - Gemfile.lock
221
226
  - MIT-LICENSE
222
227
  - README.md
223
228
  - Rakefile
@@ -228,10 +233,9 @@ files:
228
233
  - examples/sinatra/config.ru
229
234
  - examples/sinatra/sinatra_app.rb
230
235
  - exception_notification.gemspec
231
- - gemfiles/rails3_1.gemfile
232
- - gemfiles/rails3_2.gemfile
233
236
  - gemfiles/rails4_0.gemfile
234
237
  - gemfiles/rails4_1.gemfile
238
+ - gemfiles/rails4_2.gemfile
235
239
  - lib/exception_notification.rb
236
240
  - lib/exception_notification/rack.rb
237
241
  - lib/exception_notification/rails.rb
@@ -341,7 +345,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
341
345
  requirements:
342
346
  - - ">="
343
347
  - !ruby/object:Gem::Version
344
- version: 1.9.3
348
+ version: '2.0'
345
349
  required_rubygems_version: !ruby/object:Gem::Requirement
346
350
  requirements:
347
351
  - - ">="
@@ -349,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
353
  version: 1.8.11
350
354
  requirements: []
351
355
  rubyforge_project:
352
- rubygems_version: 2.2.0
356
+ rubygems_version: 2.4.5
353
357
  signing_key:
354
358
  specification_version: 4
355
359
  summary: Exception notification for Rails apps
@@ -1,174 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- exception_notification (4.1.1)
5
- actionmailer (>= 3.0.4)
6
- activesupport (>= 3.0.4)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionmailer (3.2.6)
12
- actionpack (= 3.2.6)
13
- mail (~> 2.4.4)
14
- actionpack (3.2.6)
15
- activemodel (= 3.2.6)
16
- activesupport (= 3.2.6)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- journey (~> 1.0.1)
20
- rack (~> 1.4.0)
21
- rack-cache (~> 1.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.1.3)
24
- activemodel (3.2.6)
25
- activesupport (= 3.2.6)
26
- builder (~> 3.0.0)
27
- activerecord (3.2.6)
28
- activemodel (= 3.2.6)
29
- activesupport (= 3.2.6)
30
- arel (~> 3.0.2)
31
- tzinfo (~> 0.3.29)
32
- activeresource (3.2.6)
33
- activemodel (= 3.2.6)
34
- activesupport (= 3.2.6)
35
- activesupport (3.2.6)
36
- i18n (~> 0.6)
37
- multi_json (~> 1.0)
38
- addressable (2.3.5)
39
- appraisal (1.0.0)
40
- bundler
41
- rake
42
- thor (>= 0.14.0)
43
- arel (3.0.2)
44
- builder (3.0.0)
45
- carrier-pigeon (0.7.0)
46
- addressable
47
- celluloid (0.15.2)
48
- timers (~> 1.1.0)
49
- colorize (0.5.8)
50
- connection_pool (2.0.0)
51
- coveralls (0.6.5)
52
- colorize
53
- multi_json (~> 1.3)
54
- rest-client
55
- simplecov (>= 0.7)
56
- thor
57
- erubis (2.7.0)
58
- eventmachine (1.0.3)
59
- faraday (0.8.7)
60
- multipart-post (~> 1.1)
61
- faraday_middleware (0.9.0)
62
- faraday (>= 0.7.4, < 0.9)
63
- hashie (1.2.0)
64
- hike (1.2.1)
65
- hipchat (1.2.0)
66
- httparty
67
- http_parser.rb (0.5.3)
68
- httparty (0.10.2)
69
- multi_json (~> 1.0)
70
- multi_xml (>= 0.5.2)
71
- i18n (0.6.0)
72
- journey (1.0.4)
73
- json (1.8.1)
74
- mail (2.4.4)
75
- i18n (>= 0.4.0)
76
- mime-types (~> 1.16)
77
- treetop (~> 1.4.8)
78
- metaclass (0.0.1)
79
- mime-types (1.19)
80
- mocha (0.13.3)
81
- metaclass (~> 0.0.1)
82
- multi_json (1.10.1)
83
- multi_xml (0.5.5)
84
- multipart-post (1.2.0)
85
- polyglot (0.3.3)
86
- rack (1.4.1)
87
- rack-cache (1.2)
88
- rack (>= 0.4)
89
- rack-ssl (1.3.2)
90
- rack
91
- rack-test (0.6.1)
92
- rack (>= 1.0)
93
- rails (3.2.6)
94
- actionmailer (= 3.2.6)
95
- actionpack (= 3.2.6)
96
- activerecord (= 3.2.6)
97
- activeresource (= 3.2.6)
98
- activesupport (= 3.2.6)
99
- bundler (~> 1.0)
100
- railties (= 3.2.6)
101
- railties (3.2.6)
102
- actionpack (= 3.2.6)
103
- activesupport (= 3.2.6)
104
- rack-ssl (~> 1.3.2)
105
- rake (>= 0.8.7)
106
- rdoc (~> 3.4)
107
- thor (>= 0.14.6, < 2.0)
108
- rake (0.9.2.2)
109
- rdoc (3.12)
110
- json (~> 1.4)
111
- redis (3.0.7)
112
- redis-namespace (1.4.1)
113
- redis (~> 3.0.4)
114
- resque (1.2.3)
115
- redis
116
- redis-namespace
117
- rest-client (1.6.7)
118
- mime-types (>= 1.16)
119
- sidekiq (3.0.0)
120
- celluloid (>= 0.15.2)
121
- connection_pool (>= 2.0.0)
122
- json
123
- redis (>= 3.0.6)
124
- redis-namespace (>= 1.3.1)
125
- simple_oauth (0.1.9)
126
- simplecov (0.7.1)
127
- multi_json (~> 1.0)
128
- simplecov-html (~> 0.7.1)
129
- simplecov-html (0.7.1)
130
- slack-notifier (1.0.0)
131
- sprockets (2.1.3)
132
- hike (~> 1.2)
133
- rack (~> 1.0)
134
- tilt (~> 1.1, != 1.3.0)
135
- sqlite3 (1.3.6)
136
- thor (0.15.4)
137
- tilt (1.3.3)
138
- timers (1.1.0)
139
- tinder (1.9.1)
140
- eventmachine (>= 0.12.0, < 2)
141
- faraday (~> 0.8)
142
- faraday_middleware (~> 0.8)
143
- hashie (~> 1.0)
144
- json (~> 1.6)
145
- mime-types (~> 1.16)
146
- multi_json (~> 1.0)
147
- multipart-post (~> 1.1)
148
- twitter-stream (~> 0.1)
149
- treetop (1.4.10)
150
- polyglot
151
- polyglot (>= 0.3.1)
152
- twitter-stream (0.1.16)
153
- eventmachine (>= 0.12.8)
154
- http_parser.rb (~> 0.5.1)
155
- simple_oauth (~> 0.1.4)
156
- tzinfo (0.3.33)
157
-
158
- PLATFORMS
159
- ruby
160
-
161
- DEPENDENCIES
162
- appraisal (~> 1.0.0)
163
- carrier-pigeon (>= 0.7.0)
164
- coveralls (~> 0.6.5)
165
- exception_notification!
166
- hipchat (>= 1.0.0)
167
- httparty (~> 0.10.2)
168
- mocha (>= 0.13.0)
169
- rails (>= 3.0.4)
170
- resque (~> 1.2.0)
171
- sidekiq (~> 3.0)
172
- slack-notifier (>= 1.0.0)
173
- sqlite3 (>= 1.3.4)
174
- tinder (~> 1.8)
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.0"
6
-
7
- gemspec :path => "../"