Skip to content

Commit

Permalink
Merge ab6b648 into b40e3a6
Browse files Browse the repository at this point in the history
  • Loading branch information
ampeigonet committed Jan 30, 2019
2 parents b40e3a6 + ab6b648 commit 652b3e2
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.gemfile.lock
/Gemfile.lock
/.idea/
sample_app.log
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ need contributors to follow:
like OS version, gem versions, etc...
* Even better, provide a failing test case for it.

To help you add information to an issue, you can use the sample_app.
Steps to use sample_app:

1) Add your configuration to (ex. with webhook):
```ruby
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'
}
# -----------------------------------
```

2) Run `ruby examples/sample_app.rb`
If exception notification is working OK, you'll see the message "'Raising exception!" and then "Working OK!" and should receive the notification as configured above. If it's not, you can copy the information printed on the terminal related to exception notification and report an issue with more info!

## Pull Requests

If you've gone the extra mile and have a patch that fixes the issue, you
Expand Down
62 changes: 62 additions & 0 deletions examples/sample_app.rb
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

0 comments on commit 652b3e2

Please sign in to comment.