forked from rails/exception_notification
-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.gemfile.lock | ||
/Gemfile.lock | ||
/.idea/ | ||
sample_app.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# ------------------------------------------- | ||
# To run the application: ruby examples/sample_app.rb | ||
# ------------------------------------------- | ||
|
||
require 'bundler/inline' | ||
|
||
gemfile do | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails', '5.0.0' | ||
gem 'exception_notification', '4.3.0' | ||
gem 'httparty', '0.15.7' | ||
end | ||
|
||
class SampleApp < Rails::Application | ||
config.middleware.use ExceptionNotification::Rack, | ||
# ----------------------------------- | ||
# Change this with your configuration | ||
# https://github.com/smartinez87/exception_notification#notifiers | ||
webhook: { | ||
url: 'http://domain.com:5555/hubot/path' | ||
} | ||
# ----------------------------------- | ||
|
||
config.secret_key_base = 'my secret key base' | ||
file = File.open('sample_app.log', 'w') | ||
logger = Logger.new(file) | ||
Rails.logger = logger | ||
|
||
routes.draw do | ||
get 'raise_sample_exception', to: 'exceptions#raise_sample_exception' | ||
end | ||
end | ||
|
||
require 'action_controller/railtie' | ||
require 'active_support' | ||
|
||
class ExceptionsController < ActionController::Base | ||
include Rails.application.routes.url_helpers | ||
|
||
def raise_sample_exception | ||
puts 'Raising exception!' | ||
raise 'Sample exception raised, you should receive a notification!' | ||
end | ||
end | ||
|
||
require 'minitest/autorun' | ||
|
||
class Test < Minitest::Test | ||
include Rack::Test::Methods | ||
|
||
def test_raise_exception | ||
get '/raise_sample_exception' | ||
puts "Working OK!" | ||
end | ||
|
||
private | ||
|
||
def app | ||
Rails.application | ||
end | ||
end |