exception_notification 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6bae1cf5ca412dcb05dfa6204df8a2479b622cc
4
- data.tar.gz: 51ecaf322c4f5ef0f46f2f243a793d0085051f49
3
+ metadata.gz: c6cd08f159f882bcc6c9edc00674e06c33b4f6e8
4
+ data.tar.gz: 063db2017a4336e3b3471431ebd3c5d6cb1bd80a
5
5
  SHA512:
6
- metadata.gz: 5cc6bce0dfaa2aafc646297998eea3c0b576036907b61bde5e75e9e0aaad4668060941b382291fd7e96b4f69ebd1c54cca0b806c58ff30a40dd5375c56f1f83f
7
- data.tar.gz: 949faef594436deb0a25e7c68131ba33ef1bc05b05e33c93dd773ad172139764a6a9be95dabcc2174558a9f81704fc164477d3da3846df915d27e787ef49349c
6
+ metadata.gz: 131d835c2f0375c1683d8eff1507bebf3b09cb9770ec3749ff18114789dd5152fbb75f50a7c511422ca174d55efb03ded293207f00ceb597287d8432fb2c0666
7
+ data.tar.gz: ee3de090b851c0b2e04a3a69e8841068040390ec729b60398776913b2eb26e6283e6769046cbab4cb2339baa00b3484738c8a61ba9f942870ddef0a60f2311c8
@@ -1,3 +1,9 @@
1
+ == 4.1.1
2
+
3
+ * bug fixes
4
+ * Alternate way to monkeypatch (by @joshco)
5
+ * Fix BacktraceCleaner namespacing (by @esdlocomb)
6
+
1
7
  == 4.1.0
2
8
 
3
9
  * enhancements
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exception_notification (4.1.0)
4
+ exception_notification (4.1.1)
5
5
  actionmailer (>= 3.0.4)
6
6
  activesupport (>= 3.0.4)
7
7
 
data/README.md CHANGED
@@ -39,9 +39,9 @@ gem 'exception_notification'
39
39
  As of Rails 3 ExceptionNotification is used as a rack middleware, or in the environment you want it to run. In most cases you would want ExceptionNotification to run on production. Thus, you can make it work by putting the following lines in your `config/environments/production.rb`:
40
40
 
41
41
  ```ruby
42
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
42
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
43
43
  :email => {
44
- :email_prefix => "[Whatever] ",
44
+ :email_prefix => "[PREFIX] ",
45
45
  :sender_address => %{"notifier" <notifier@example.com>},
46
46
  :exception_recipients => %w{exceptions@example.com}
47
47
  }
@@ -58,8 +58,8 @@ In order to use ExceptionNotification with Sinatra, please take a look in the [e
58
58
  As of 4.x version the configuration syntax has changed. All email related options MUST BE nested under the `:email` key. Thus, previous configuration like:
59
59
 
60
60
  ```ruby
61
- Whatever::Application.config.middleware.use ExceptionNotifier,
62
- :email_prefix => "[Whatever] ",
61
+ Rails.application.config.middleware.use ExceptionNotifier,
62
+ :email_prefix => "[PREFIX] ",
63
63
  :sender_address => %{"notifier" <notifier@example.com>},
64
64
  :exception_recipients => %w{exceptions@example.com}
65
65
  ```
@@ -67,9 +67,9 @@ Whatever::Application.config.middleware.use ExceptionNotifier,
67
67
  becomes:
68
68
 
69
69
  ```ruby
70
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
70
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
71
71
  :email => {
72
- :email_prefix => "[Whatever] ",
72
+ :email_prefix => "[PREFIX] ",
73
73
  :sender_address => %{"notifier" <notifier@example.com>},
74
74
  :exception_recipients => %w{exceptions@example.com}
75
75
  }
@@ -145,9 +145,9 @@ You can reorder the sections, or exclude sections completely, by using `sections
145
145
  describe application-specific data--just add the section's name to the list (wherever you'd like), and define the corresponding partial. Like the following example with two new added sections:
146
146
 
147
147
  ```ruby
148
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
148
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
149
149
  :email => {
150
- :email_prefix => "[Whatever] ",
150
+ :email_prefix => "[PREFIX] ",
151
151
  :sender_address => %{"notifier" <notifier@example.com>},
152
152
  :exception_recipients => %w{exceptions@example.com},
153
153
  :sections => %w{my_section1 my_section2}
@@ -183,9 +183,9 @@ In the above case, `@document` and `@person` would be made available to the emai
183
183
  When using [background notifications](#background-notifications) some variables are not available in the views, like `@kontroller` and `@request`. Thus, you may want to include different sections for background notifications:
184
184
 
185
185
  ```ruby
186
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
186
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
187
187
  :email => {
188
- :email_prefix => "[Whatever] ",
188
+ :email_prefix => "[PREFIX] ",
189
189
  :sender_address => %{"notifier" <notifier@example.com>},
190
190
  :exception_recipients => %w{exceptions@example.com},
191
191
  :background_sections => %w{my_section1 my_section2 backtrace data}
@@ -200,9 +200,9 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
200
200
  Additionally, you may want to set customized headers on the outcoming emails. To do so, simply use the `:email_headers` option:
201
201
 
202
202
  ```ruby
203
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
203
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
204
204
  :email => {
205
- :email_prefix => "[Whatever] ",
205
+ :email_prefix => "[PREFIX] ",
206
206
  :sender_address => %{"notifier" <notifier@example.com>},
207
207
  :exception_recipients => %w{exceptions@example.com},
208
208
  :email_headers => { "X-Custom-Header" => "foobar" }
@@ -238,9 +238,9 @@ By default, ExceptionNotification sends emails in plain text, in order to sends
238
238
  By default, ExceptionNotification sends emails using the ActionMailer configuration of the application. In order to send emails by another delivery method, use the `delivery_method` option:
239
239
 
240
240
  ```ruby
241
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
241
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
242
242
  :email => {
243
- :email_prefix => "[Whatever] ",
243
+ :email_prefix => "[PREFIX] ",
244
244
  :sender_address => %{"notifier" <notifier@example.com>},
245
245
  :exception_recipients => %w{exceptions@example.com},
246
246
  :delivery_method => :postmark,
@@ -253,9 +253,9 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
253
253
  Besides the `delivery_method` option, you also can customize the mailer settings by passing a hash under an option named `DELIVERY_METHOD_settings`. Thus, you can use override specific SMTP settings for notifications using:
254
254
 
255
255
  ```ruby
256
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
256
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
257
257
  :email => {
258
- :email_prefix => "[Whatever] ",
258
+ :email_prefix => "[PREFIX] ",
259
259
  :sender_address => %{"notifier" <notifier@example.com>},
260
260
  :exception_recipients => %w{exceptions@example.com},
261
261
  :delivery_method => :smtp,
@@ -291,9 +291,9 @@ gem 'tinder'
291
291
  To configure it, you need to set the `subdomain`, `token` and `room_name` options, like this:
292
292
 
293
293
  ```ruby
294
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
294
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
295
295
  :email => {
296
- :email_prefix => "[Whatever] ",
296
+ :email_prefix => "[PREFIX] ",
297
297
  :sender_address => %{"notifier" <notifier@example.com>},
298
298
  :exception_recipients => %w{exceptions@example.com}
299
299
  },
@@ -343,9 +343,9 @@ gem 'hipchat'
343
343
  To configure it, you need to set the `token` and `room_name` options, like this:
344
344
 
345
345
  ```ruby
346
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
346
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
347
347
  :email => {
348
- :email_prefix => "[Whatever] ",
348
+ :email_prefix => "[PREFIX] ",
349
349
  :sender_address => %{"notifier" <notifier@example.com>},
350
350
  :exception_recipients => %w{exceptions@example.com}
351
351
  },
@@ -404,9 +404,9 @@ gem 'httparty'
404
404
  To configure it, you need to set the `url` option, like this:
405
405
 
406
406
  ```ruby
407
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
407
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
408
408
  :email => {
409
- :email_prefix => "[Whatever] ",
409
+ :email_prefix => "[PREFIX] ",
410
410
  :sender_address => %{"notifier" <notifier@example.com>},
411
411
  :exception_recipients => %w{exceptions@example.com}
412
412
  },
@@ -418,9 +418,9 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
418
418
  By default, the WebhookNotifier will call the URLs using the POST method. But, you can change this using the `http_method` option.
419
419
 
420
420
  ```ruby
421
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
421
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
422
422
  :email => {
423
- :email_prefix => "[Whatever] ",
423
+ :email_prefix => "[PREFIX] ",
424
424
  :sender_address => %{"notifier" <notifier@example.com>},
425
425
  :exception_recipients => %w{exceptions@example.com}
426
426
  },
@@ -433,9 +433,9 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
433
433
  Besides the `url` and `http_method` options, all the other options are passed directly to HTTParty. Thus, if the HTTP server requires authentication, you can include the following options:
434
434
 
435
435
  ```ruby
436
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
436
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
437
437
  :email => {
438
- :email_prefix => "[Whatever] ",
438
+ :email_prefix => "[PREFIX] ",
439
439
  :sender_address => %{"notifier" <notifier@example.com>},
440
440
  :exception_recipients => %w{exceptions@example.com}
441
441
  },
@@ -465,9 +465,9 @@ gem 'carrier-pigeon'
465
465
  To configure it, you need to set at least the 'domain' option, like this:
466
466
 
467
467
  ```ruby
468
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
468
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
469
469
  :email => {
470
- :email_prefix => "[Whatever] ",
470
+ :email_prefix => "[PREFIX] ",
471
471
  :sender_address => %{"notifier" <notifier@example.com>},
472
472
  :exception_recipients => %w{exceptions@example.com}
473
473
  },
@@ -479,7 +479,7 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
479
479
  There are several other options, which are described below. For example, to use ssl and a password, add a prefix, post to the '#log' channel, and include recipients in the message (so that they will be notified), your configuration might look like this:
480
480
 
481
481
  ```ruby
482
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
482
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
483
483
  :irc => {
484
484
  :domain => 'irc.example.com',
485
485
  :nick => 'BadNewsBot',
@@ -564,9 +564,9 @@ gem 'slack-notifier'
564
564
  To configure it, you need to set at least the 'webhook_url' option, like this:
565
565
 
566
566
  ```ruby
567
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
567
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
568
568
  :email => {
569
- :email_prefix => "[Whatever] ",
569
+ :email_prefix => "[PREFIX] ",
570
570
  :sender_address => %{"notifier" <notifier@example.com>},
571
571
  :exception_recipients => %w{exceptions@example.com}
572
572
  },
@@ -583,7 +583,7 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
583
583
  The slack notification will include any data saved under `env["exception_notifier.exception_data"]`. If you find this too verbose, you can determine to exclude certain information by doing the following:
584
584
 
585
585
  ```ruby
586
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
586
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
587
587
  :slack => {
588
588
  :webhook_url => "[Your webhook url]",
589
589
  :channel => "#exceptions",
@@ -664,9 +664,9 @@ end
664
664
  Using it:
665
665
 
666
666
  ```ruby
667
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
667
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
668
668
  :email => {
669
- :email_prefix => "[Whatever] ",
669
+ :email_prefix => "[PREFIX] ",
670
670
  :sender_address => %{"notifier" <notifier@example.com>},
671
671
  :exception_recipients => %w{exceptions@example.com}
672
672
  },
@@ -694,10 +694,10 @@ You can choose to ignore certain exceptions, which will make ExceptionNotificati
694
694
  Ignore specified exception types. To achieve that, you should use the `:ignore_exceptions` option, like this:
695
695
 
696
696
  ```ruby
697
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
697
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
698
698
  :ignore_exceptions => ['ActionView::TemplateError'] + ExceptionNotifier.ignored_exceptions,
699
699
  :email => {
700
- :email_prefix => "[Whatever] ",
700
+ :email_prefix => "[PREFIX] ",
701
701
  :sender_address => %{"notifier" <notifier@example.com>},
702
702
  :exception_recipients => %w{exceptions@example.com}
703
703
  }
@@ -712,10 +712,10 @@ The above will make ExceptionNotifier ignore a *TemplateError* exception, plus t
712
712
  In some cases you may want to avoid getting notifications from exceptions made by crawlers. To prevent sending those unwanted notifications, use the `:ignore_crawlers` option like this:
713
713
 
714
714
  ```ruby
715
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
715
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
716
716
  :ignore_crawlers => %w{Googlebot bingbot},
717
717
  :email => {
718
- :email_prefix => "[Whatever] ",
718
+ :email_prefix => "[PREFIX] ",
719
719
  :sender_address => %{"notifier" <notifier@example.com>},
720
720
  :exception_recipients => %w{exceptions@example.com}
721
721
  }
@@ -728,10 +728,10 @@ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
728
728
  Last but not least, you can ignore exceptions based on a condition. Take a look:
729
729
 
730
730
  ```ruby
731
- Whatever::Application.config.middleware.use ExceptionNotification::Rack,
731
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
732
732
  :ignore_if => ->(env, exception) { exception.message =~ /^Couldn't find Page with ID=/ },
733
733
  :email => {
734
- :email_prefix => "[Whatever] ",
734
+ :email_prefix => "[PREFIX] ",
735
735
  :sender_address => %{"notifier" <notifier@example.com>},
736
736
  :exception_recipients => %w{exceptions@example.com},
737
737
  }
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'exception_notification'
3
- s.version = '4.1.0'
3
+ s.version = '4.1.1'
4
4
  s.authors = ["Jamis Buck", "Josh Peek"]
5
- s.date = %q{2015-04-05}
5
+ s.date = %q{2015-06-09}
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"
@@ -17,7 +17,7 @@ module ExceptionNotifier
17
17
 
18
18
  def self.extended(base)
19
19
  base.class_eval do
20
- base.include BacktraceCleaner
20
+ self.send(:include, ExceptionNotifier::BacktraceCleaner)
21
21
 
22
22
  # Append application view path to the ExceptionNotifier lookup context.
23
23
  self.append_view_path "#{File.dirname(__FILE__)}/views"
@@ -1,11 +1,13 @@
1
- module BacktraceCleaner
1
+ module ExceptionNotifier
2
+ module BacktraceCleaner
2
3
 
3
- def clean_backtrace(exception)
4
- if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
5
- Rails.backtrace_cleaner.send(:filter, exception.backtrace)
6
- else
7
- exception.backtrace
4
+ def clean_backtrace(exception)
5
+ if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
6
+ Rails.backtrace_cleaner.send(:filter, exception.backtrace)
7
+ else
8
+ exception.backtrace
9
+ end
8
10
  end
9
- end
10
11
 
12
+ end
11
13
  end
@@ -1,6 +1,6 @@
1
1
  module ExceptionNotifier
2
2
  class SlackNotifier
3
- include BacktraceCleaner
3
+ include ExceptionNotifier::BacktraceCleaner
4
4
 
5
5
  attr_accessor :notifier
6
6
 
@@ -14,59 +14,59 @@ class PostsControllerTest < ActionController::TestCase
14
14
  end
15
15
 
16
16
  test "should have raised an exception" do
17
- assert_not_nil @exception
17
+ refute_nil @exception
18
18
  end
19
19
 
20
20
  test "should have generated a notification email" do
21
- assert_not_nil @mail
21
+ refute_nil @mail
22
22
  end
23
23
 
24
24
  test "mail should be plain text and UTF-8 enconded by default" do
25
- assert @mail.content_type == "text/plain; charset=UTF-8"
25
+ assert_equal @mail.content_type, "text/plain; charset=UTF-8"
26
26
  end
27
27
 
28
28
  test "mail should have a from address set" do
29
- assert @mail.from == ["dummynotifier@example.com"]
29
+ assert_equal @mail.from, ["dummynotifier@example.com"]
30
30
  end
31
31
 
32
32
  test "mail should have a to address set" do
33
- assert @mail.to == ["dummyexceptions@example.com"]
33
+ assert_equal @mail.to, ["dummyexceptions@example.com"]
34
34
  end
35
35
 
36
36
  test "mail subject should have the proper prefix" do
37
- assert @mail.subject.include? "[Dummy ERROR]"
37
+ assert_includes @mail.subject, "[Dummy ERROR]"
38
38
  end
39
39
 
40
40
  test "mail subject should include descriptive error message" do
41
- assert @mail.subject.include? "(NoMethodError) \"undefined method `nw'"
41
+ assert_includes @mail.subject, "(NoMethodError) \"undefined method `nw'"
42
42
  end
43
43
 
44
44
  test "mail should contain backtrace in body" do
45
- assert @mail.encoded.include? "`method_missing'\r\n app/controllers/posts_controller.rb:18:in `create'\r\n"
45
+ assert_includes @mail.encoded, "`method_missing'\r\n app/controllers/posts_controller.rb:18:in `create'\r\n"
46
46
  end
47
47
 
48
48
  test "mail should contain timestamp of exception in body" do
49
- assert @mail.encoded.include? "Timestamp : #{Time.current}"
49
+ assert_includes @mail.encoded, "Timestamp : #{Time.current}"
50
50
  end
51
51
 
52
52
  test "mail should contain the newly defined section" do
53
- assert @mail.encoded.include? "* New text section for testing"
53
+ assert_includes @mail.encoded, "* New text section for testing"
54
54
  end
55
55
 
56
56
  test "mail should contain the custom message" do
57
- assert @mail.encoded.include? "My Custom Message"
57
+ assert_includes @mail.encoded, "My Custom Message"
58
58
  end
59
59
 
60
60
  test "should filter sensible data" do
61
- assert @mail.encoded.include? "secret\"=>\"[FILTERED]"
61
+ assert_includes @mail.encoded, "secret\"=>\"[FILTERED]"
62
62
  end
63
63
 
64
64
  test "mail should contain the custom header" do
65
- assert @mail.encoded.include? 'X-Custom-Header: foobar'
65
+ assert_includes @mail.encoded, 'X-Custom-Header: foobar'
66
66
  end
67
67
 
68
68
  test "mail should not contain any attachments" do
69
- assert @mail.attachments == []
69
+ assert_equal @mail.attachments, []
70
70
  end
71
71
 
72
72
  test "should not send notification if one of ignored exceptions" do
@@ -79,7 +79,7 @@ class PostsControllerTest < ActionController::TestCase
79
79
  end
80
80
  end
81
81
 
82
- assert @ignored_exception.class.inspect == "ActiveRecord::RecordNotFound"
82
+ assert_equal @ignored_exception.class.inspect, "ActiveRecord::RecordNotFound"
83
83
  assert_nil @ignored_mail
84
84
  end
85
85
 
@@ -93,7 +93,7 @@ class PostsControllerTest < ActionController::TestCase
93
93
  end
94
94
 
95
95
  assert request.ssl?
96
- assert @secured_mail.encoded.include? "* session id: [FILTERED]\r\n *"
96
+ assert_includes @secured_mail.encoded, "* session id: [FILTERED]\r\n *"
97
97
  end
98
98
 
99
99
  test "should ignore exception if from unwanted crawler" do
@@ -127,7 +127,7 @@ class PostsControllerTest < ActionController::TestCase
127
127
  @mail = @email_notifier.create_email(@exception, {:env => custom_env})
128
128
  end
129
129
 
130
- assert @mail.content_type.include? "multipart/alternative"
130
+ assert_includes @mail.content_type, "multipart/alternative"
131
131
  end
132
132
  end
133
133
 
@@ -219,6 +219,6 @@ class PostsControllerTestBackgroundNotification < ActionController::TestCase
219
219
  end
220
220
 
221
221
  test "mail should contain the specified section" do
222
- assert @mail.encoded.include? "* New background section for testing"
222
+ assert_includes @mail.encoded, "* New background section for testing"
223
223
  end
224
224
  end
@@ -11,9 +11,9 @@ class CampfireNotifierTest < ActiveSupport::TestCase
11
11
 
12
12
  assert !notif[:message].empty?
13
13
  assert_equal notif[:message][:type], 'PasteMessage'
14
- assert notif[:message][:body].include? "A new exception occurred:"
15
- assert notif[:message][:body].include? "divided by 0"
16
- assert notif[:message][:body].include? "/exception_notification/test/campfire_test.rb:45"
14
+ assert_includes notif[:message][:body], "A new exception occurred:"
15
+ assert_includes notif[:message][:body], "divided by 0"
16
+ assert_includes notif[:message][:body], "/exception_notification/test/campfire_test.rb:45"
17
17
  end
18
18
 
19
19
  test "should not send campfire notification if badly configured" do
@@ -14,59 +14,59 @@ class EmailNotifierTest < ActiveSupport::TestCase
14
14
  end
15
15
 
16
16
  test "should have default sender address overridden" do
17
- assert @email_notifier.sender_address == %("Dummy Notifier" <dummynotifier@example.com>)
17
+ assert_equal @email_notifier.sender_address, %("Dummy Notifier" <dummynotifier@example.com>)
18
18
  end
19
19
 
20
20
  test "should have default exception recipients overridden" do
21
- assert @email_notifier.exception_recipients == %w(dummyexceptions@example.com)
21
+ assert_equal @email_notifier.exception_recipients, %w(dummyexceptions@example.com)
22
22
  end
23
23
 
24
24
  test "should have default email prefix overridden" do
25
- assert @email_notifier.email_prefix == "[Dummy ERROR] "
25
+ assert_equal @email_notifier.email_prefix, "[Dummy ERROR] "
26
26
  end
27
27
 
28
28
  test "should have default email headers overridden" do
29
- assert @email_notifier.email_headers == { "X-Custom-Header" => "foobar"}
29
+ assert_equal @email_notifier.email_headers, { "X-Custom-Header" => "foobar"}
30
30
  end
31
31
 
32
32
  test "should have default sections overridden" do
33
33
  for section in %w(new_section request session environment backtrace)
34
- assert @email_notifier.sections.include? section
34
+ assert_includes @email_notifier.sections, section
35
35
  end
36
36
  end
37
37
 
38
38
  test "should have default background sections" do
39
39
  for section in %w(new_bkg_section backtrace data)
40
- assert @email_notifier.background_sections.include? section
40
+ assert_includes @email_notifier.background_sections, section
41
41
  end
42
42
  end
43
43
 
44
44
  test "should have email format by default" do
45
- assert @email_notifier.email_format == :text
45
+ assert_equal @email_notifier.email_format, :text
46
46
  end
47
47
 
48
48
  test "should have verbose subject by default" do
49
- assert @email_notifier.verbose_subject == true
49
+ assert @email_notifier.verbose_subject
50
50
  end
51
51
 
52
52
  test "should have normalize_subject false by default" do
53
- assert @email_notifier.normalize_subject == false
53
+ refute @email_notifier.normalize_subject
54
54
  end
55
55
 
56
56
  test "should have delivery_method nil by default" do
57
- assert @email_notifier.delivery_method == nil
57
+ assert_nil @email_notifier.delivery_method
58
58
  end
59
59
 
60
60
  test "should have mailer_settings nil by default" do
61
- assert @email_notifier.mailer_settings == nil
61
+ assert_nil @email_notifier.mailer_settings
62
62
  end
63
63
 
64
64
  test "should have mailer_parent by default" do
65
- assert @email_notifier.mailer_parent == 'ActionMailer::Base'
65
+ assert_equal @email_notifier.mailer_parent, 'ActionMailer::Base'
66
66
  end
67
67
 
68
68
  test "should have template_path by default" do
69
- assert @email_notifier.template_path == 'exception_notifier'
69
+ assert_equal @email_notifier.template_path, 'exception_notifier'
70
70
  end
71
71
 
72
72
  test "should normalize multiple digits into one N" do
@@ -75,31 +75,39 @@ class EmailNotifierTest < ActiveSupport::TestCase
75
75
  end
76
76
 
77
77
  test "mail should be plain text and UTF-8 enconded by default" do
78
- assert @mail.content_type == "text/plain; charset=UTF-8"
78
+ assert_equal @mail.content_type, "text/plain; charset=UTF-8"
79
79
  end
80
80
 
81
81
  test "should have raised an exception" do
82
- assert_not_nil @exception
82
+ refute_nil @exception
83
83
  end
84
84
 
85
85
  test "should have generated a notification email" do
86
- assert_not_nil @mail
86
+ refute_nil @mail
87
87
  end
88
88
 
89
89
  test "mail should have a from address set" do
90
- assert @mail.from == ["dummynotifier@example.com"]
90
+ assert_equal @mail.from, ["dummynotifier@example.com"]
91
91
  end
92
92
 
93
93
  test "mail should have a to address set" do
94
- assert @mail.to == ["dummyexceptions@example.com"]
94
+ assert_equal @mail.to, ["dummyexceptions@example.com"]
95
95
  end
96
96
 
97
97
  test "mail should have a descriptive subject" do
98
- assert @mail.subject == "[Dummy ERROR] (ZeroDivisionError) \"divided by 0\""
98
+ # On Rails < 4.1 the subject prefix has two spaces before the rest of the
99
+ # subject content.
100
+ if Gem::Version.new(ActionMailer::VERSION::STRING) < Gem::Version.new('4.1')
101
+ prefix = '[Dummy ERROR] '
102
+ else
103
+ # On Rails 4.1 the subject prefix has a single space.
104
+ prefix = '[Dummy ERROR] '
105
+ end
106
+ assert_equal @mail.subject, prefix + '(ZeroDivisionError) "divided by 0"'
99
107
  end
100
108
 
101
109
  test "mail should say exception was raised in background at show timestamp" do
102
- assert @mail.encoded.include? "A ZeroDivisionError occurred in background at #{Time.current}"
110
+ assert_includes @mail.encoded, "A ZeroDivisionError occurred in background at #{Time.current}"
103
111
  end
104
112
 
105
113
  test "mail should prefix exception class with 'an' instead of 'a' when it starts with a vowel" do
@@ -110,7 +118,7 @@ class EmailNotifierTest < ActiveSupport::TestCase
110
118
  @vowel_mail = @email_notifier.create_email(@vowel_exception)
111
119
  end
112
120
 
113
- assert @vowel_mail.encoded.include? "An ActiveRecord::RecordNotFound occurred in background at #{Time.current}"
121
+ assert_includes @vowel_mail.encoded, "An ActiveRecord::RecordNotFound occurred in background at #{Time.current}"
114
122
  end
115
123
 
116
124
  test "mail should contain backtrace in body" do
@@ -118,14 +126,14 @@ class EmailNotifierTest < ActiveSupport::TestCase
118
126
  end
119
127
 
120
128
  test "mail should contain data in body" do
121
- assert @mail.encoded.include? '* data:'
122
- assert @mail.encoded.include? ':payload=>"1/0"'
123
- assert @mail.encoded.include? ':job=>"DivideWorkerJob"'
124
- assert @mail.encoded.include? "My Custom Message"
129
+ assert_includes @mail.encoded, '* data:'
130
+ assert_includes @mail.encoded, ':payload=>"1/0"'
131
+ assert_includes @mail.encoded, ':job=>"DivideWorkerJob"'
132
+ assert_includes @mail.encoded, "My Custom Message"
125
133
  end
126
134
 
127
135
  test "mail should not contain any attachments" do
128
- assert @mail.attachments == []
136
+ assert_equal @mail.attachments, []
129
137
  end
130
138
 
131
139
  test "should not send notification if one of ignored exceptions" do
@@ -138,7 +146,7 @@ class EmailNotifierTest < ActiveSupport::TestCase
138
146
  end
139
147
  end
140
148
 
141
- assert @ignored_exception.class.inspect == "ActiveRecord::RecordNotFound"
149
+ assert_equal @ignored_exception.class.inspect, "ActiveRecord::RecordNotFound"
142
150
  assert_nil @ignored_mail
143
151
  end
144
152
  end
@@ -9,11 +9,11 @@ class WebhookNotifierTest < ActiveSupport::TestCase
9
9
  webhook.stubs(:call).returns(fake_response)
10
10
  response = webhook.call(fake_exception)
11
11
 
12
- assert_not_nil response
12
+ refute_nil response
13
13
  assert_equal response[:status], 200
14
14
  assert_equal response[:body][:exception][:error_class], "ZeroDivisionError"
15
- assert response[:body][:exception][:message].include? "divided by 0"
16
- assert response[:body][:exception][:backtrace].include? "/exception_notification/test/webhook_notifier_test.rb:48"
15
+ assert_includes response[:body][:exception][:message], "divided by 0"
16
+ assert_includes response[:body][:exception][:backtrace], "/exception_notification/test/webhook_notifier_test.rb:48"
17
17
 
18
18
  assert response[:body][:request][:cookies].has_key?(:cookie_item1)
19
19
  assert_equal response[:body][:request][:url], "http://example.com/example"
@@ -2,18 +2,18 @@ require 'test_helper'
2
2
 
3
3
  class ExceptionNotifierTest < ActiveSupport::TestCase
4
4
  test "should have default ignored exceptions" do
5
- assert ExceptionNotifier.ignored_exceptions == ['ActiveRecord::RecordNotFound', 'AbstractController::ActionNotFound', 'ActionController::RoutingError', 'ActionController::UnknownFormat']
5
+ assert_equal ExceptionNotifier.ignored_exceptions, ['ActiveRecord::RecordNotFound', 'AbstractController::ActionNotFound', 'ActionController::RoutingError', 'ActionController::UnknownFormat']
6
6
  end
7
7
 
8
8
  test "should have email notifier registered" do
9
- assert ExceptionNotifier.notifiers == [:email]
9
+ assert_equal ExceptionNotifier.notifiers, [:email]
10
10
  end
11
11
 
12
12
  test "should have a valid email notifier" do
13
13
  @email_notifier = ExceptionNotifier.registered_exception_notifier(:email)
14
- assert_not_nil @email_notifier
15
- assert @email_notifier.class == ExceptionNotifier::EmailNotifier
16
- assert @email_notifier.respond_to?(:call)
14
+ refute_nil @email_notifier
15
+ assert_equal @email_notifier.class, ExceptionNotifier::EmailNotifier
16
+ assert_respond_to @email_notifier, :call
17
17
  end
18
18
 
19
19
  test "should allow register/unregister another notifier" do
@@ -21,14 +21,14 @@ class ExceptionNotifierTest < ActiveSupport::TestCase
21
21
  proc_notifier = lambda { |exception, options| called = true }
22
22
  ExceptionNotifier.register_exception_notifier(:proc, proc_notifier)
23
23
 
24
- assert ExceptionNotifier.notifiers.sort == [:email, :proc]
24
+ assert_equal ExceptionNotifier.notifiers.sort, [:email, :proc]
25
25
 
26
26
  exception = StandardError.new
27
27
  ExceptionNotifier.notify_exception(exception)
28
- assert called == true
28
+ assert called
29
29
 
30
30
  ExceptionNotifier.unregister_exception_notifier(:proc)
31
- assert ExceptionNotifier.notifiers == [:email]
31
+ assert_equal ExceptionNotifier.notifiers, [:email]
32
32
  end
33
33
 
34
34
  test "should allow select notifiers to send error to" do
@@ -40,24 +40,24 @@ class ExceptionNotifierTest < ActiveSupport::TestCase
40
40
  notifier2 = lambda { |exception, options| notifier2_calls += 1 }
41
41
  ExceptionNotifier.register_exception_notifier(:notifier2, notifier2)
42
42
 
43
- assert ExceptionNotifier.notifiers.sort == [:email, :notifier1, :notifier2]
43
+ assert_equal ExceptionNotifier.notifiers.sort, [:email, :notifier1, :notifier2]
44
44
 
45
45
  exception = StandardError.new
46
46
  ExceptionNotifier.notify_exception(exception)
47
- assert notifier1_calls == 1
48
- assert notifier2_calls == 1
47
+ assert_equal notifier1_calls, 1
48
+ assert_equal notifier2_calls, 1
49
49
 
50
50
  ExceptionNotifier.notify_exception(exception, {:notifiers => :notifier1})
51
- assert notifier1_calls == 2
52
- assert notifier2_calls == 1
51
+ assert_equal notifier1_calls, 2
52
+ assert_equal notifier2_calls, 1
53
53
 
54
54
  ExceptionNotifier.notify_exception(exception, {:notifiers => :notifier2})
55
- assert notifier1_calls == 2
56
- assert notifier2_calls == 2
55
+ assert_equal notifier1_calls, 2
56
+ assert_equal notifier2_calls, 2
57
57
 
58
58
  ExceptionNotifier.unregister_exception_notifier(:notifier1)
59
59
  ExceptionNotifier.unregister_exception_notifier(:notifier2)
60
- assert ExceptionNotifier.notifiers == [:email]
60
+ assert_equal ExceptionNotifier.notifiers, [:email]
61
61
  end
62
62
 
63
63
  test "should ignore exception if satisfies conditional ignore" do
@@ -73,11 +73,11 @@ class ExceptionNotifierTest < ActiveSupport::TestCase
73
73
  exception = StandardError.new
74
74
 
75
75
  ExceptionNotifier.notify_exception(exception, {:notifiers => :test})
76
- assert notifier_calls == 1
76
+ assert_equal notifier_calls, 1
77
77
 
78
78
  env = "development"
79
79
  ExceptionNotifier.notify_exception(exception, {:notifiers => :test})
80
- assert notifier_calls == 1
80
+ assert_equal notifier_calls, 1
81
81
 
82
82
  ExceptionNotifier.clear_ignore_conditions!
83
83
  ExceptionNotifier.unregister_exception_notifier(:test)
@@ -91,10 +91,10 @@ class ExceptionNotifierTest < ActiveSupport::TestCase
91
91
  exception = StandardError.new
92
92
 
93
93
  ExceptionNotifier.notify_exception(exception, {:notifiers => :test})
94
- assert notifier_calls == 1
94
+ assert_equal notifier_calls, 1
95
95
 
96
96
  ExceptionNotifier.notify_exception(exception, {:notifiers => :test, :ignore_exceptions => 'StandardError' })
97
- assert notifier_calls == 1
97
+ assert_equal notifier_calls, 1
98
98
 
99
99
  ExceptionNotifier.unregister_exception_notifier(:test)
100
100
  end
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.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-05 00:00:00.000000000 Z
12
+ date: 2015-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer