Commit f45f759b3e6afd6b98bdc24c74268d5e81a837ee
1 parent
e77f238e
Exists in
master
and in
1 other branch
Let's call errors errs
Showing
18 changed files
with
68 additions
and
67 deletions
Show diff stats
app/controllers/apps_controller.rb
| @@ -33,7 +33,7 @@ class AppsController < ApplicationController | @@ -33,7 +33,7 @@ class AppsController < ApplicationController | ||
| 33 | def update | 33 | def update |
| 34 | @app = App.find(params[:id]) | 34 | @app = App.find(params[:id]) |
| 35 | 35 | ||
| 36 | - if @app.update_attributes!(params[:app]) | 36 | + if @app.update_attributes(params[:app]) |
| 37 | flash[:success] = "Good news everyone! '#{@app.name}' was successfully updated." | 37 | flash[:success] = "Good news everyone! '#{@app.name}' was successfully updated." |
| 38 | redirect_to app_path(@app) | 38 | redirect_to app_path(@app) |
| 39 | else | 39 | else |
app/controllers/errs_controller.rb
| @@ -24,7 +24,7 @@ class ErrsController < ApplicationController | @@ -24,7 +24,7 @@ class ErrsController < ApplicationController | ||
| 24 | 24 | ||
| 25 | @err.resolve! | 25 | @err.resolve! |
| 26 | 26 | ||
| 27 | - flash[:success] = 'Great news everyone! The error has been resolved.' | 27 | + flash[:success] = 'Great news everyone! The err has been resolved.' |
| 28 | redirect_to errs_path | 28 | redirect_to errs_path |
| 29 | end | 29 | end |
| 30 | 30 |
app/mailers/mailer.rb
| @@ -2,7 +2,7 @@ class Mailer < ActionMailer::Base | @@ -2,7 +2,7 @@ class Mailer < ActionMailer::Base | ||
| 2 | default :from => Errbit::Config.email_from | 2 | default :from => Errbit::Config.email_from |
| 3 | default_url_options[:host] = Errbit::Config.host | 3 | default_url_options[:host] = Errbit::Config.host |
| 4 | 4 | ||
| 5 | - def error_notification(notice) | 5 | + def err_notification(notice) |
| 6 | @notice = notice | 6 | @notice = notice |
| 7 | @app = notice.err.app | 7 | @app = notice.err.app |
| 8 | 8 |
app/models/app.rb
| @@ -14,7 +14,8 @@ class App | @@ -14,7 +14,8 @@ class App | ||
| 14 | before_validation :generate_api_key, :on => :create | 14 | before_validation :generate_api_key, :on => :create |
| 15 | 15 | ||
| 16 | validates_presence_of :name, :api_key | 16 | validates_presence_of :name, :api_key |
| 17 | - validates_uniqueness_of :name, :api_key, :allow_blank => true, :on => :create | 17 | + validates_uniqueness_of :name, :allow_blank => true |
| 18 | + validates_uniqueness_of :api_key, :allow_blank => true | ||
| 18 | 19 | ||
| 19 | accepts_nested_attributes_for :watchers, :allow_destroy => true, | 20 | accepts_nested_attributes_for :watchers, :allow_destroy => true, |
| 20 | :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } | 21 | :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } |
app/models/notice.rb
| @@ -26,7 +26,7 @@ class Notice | @@ -26,7 +26,7 @@ class Notice | ||
| 26 | hoptoad_notice['request']['component'] = 'unknown' if hoptoad_notice['request']['component'].blank? | 26 | hoptoad_notice['request']['component'] = 'unknown' if hoptoad_notice['request']['component'].blank? |
| 27 | hoptoad_notice['request']['action'] = nil if hoptoad_notice['request']['action'].blank? | 27 | hoptoad_notice['request']['action'] = nil if hoptoad_notice['request']['action'].blank? |
| 28 | 28 | ||
| 29 | - error = Err.for({ | 29 | + err = Err.for({ |
| 30 | :app => app, | 30 | :app => app, |
| 31 | :klass => hoptoad_notice['error']['class'], | 31 | :klass => hoptoad_notice['error']['class'], |
| 32 | :component => hoptoad_notice['request']['component'], | 32 | :component => hoptoad_notice['request']['component'], |
| @@ -35,7 +35,7 @@ class Notice | @@ -35,7 +35,7 @@ class Notice | ||
| 35 | :fingerprint => hoptoad_notice['fingerprint'] | 35 | :fingerprint => hoptoad_notice['fingerprint'] |
| 36 | }) | 36 | }) |
| 37 | 37 | ||
| 38 | - error.notices.create!({ | 38 | + err.notices.create!({ |
| 39 | :message => hoptoad_notice['error']['message'], | 39 | :message => hoptoad_notice['error']['message'], |
| 40 | :backtrace => hoptoad_notice['error']['backtrace']['line'], | 40 | :backtrace => hoptoad_notice['error']['backtrace']['line'], |
| 41 | :server_environment => hoptoad_notice['server-environment'], | 41 | :server_environment => hoptoad_notice['server-environment'], |
| @@ -61,7 +61,7 @@ class Notice | @@ -61,7 +61,7 @@ class Notice | ||
| 61 | end | 61 | end |
| 62 | 62 | ||
| 63 | def deliver_notification | 63 | def deliver_notification |
| 64 | - Mailer.error_notification(self).deliver | 64 | + Mailer.err_notification(self).deliver |
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | def cache_last_notice_at | 67 | def cache_last_notice_at |
app/views/apps/_fields.html.haml
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | %div.checkbox | 5 | %div.checkbox |
| 6 | = f.check_box :resolve_errs_on_deploy | 6 | = f.check_box :resolve_errs_on_deploy |
| 7 | - = f.label :resolve_errs_on_deploy, 'Resolve errors on deploy' | 7 | + = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' |
| 8 | 8 | ||
| 9 | %fieldset.nested-wrapper | 9 | %fieldset.nested-wrapper |
| 10 | %legend Watchers | 10 | %legend Watchers |
app/views/apps/index.html.haml
app/views/apps/show.html.haml
| 1 | - content_for :title, @app.name | 1 | - content_for :title, @app.name |
| 2 | - content_for :meta do | 2 | - content_for :meta do |
| 3 | - %strong Errors Caught: | 3 | + %strong Errs Caught: |
| 4 | = @app.errs.count | 4 | = @app.errs.count |
| 5 | %strong API Key: | 5 | %strong API Key: |
| 6 | = @app.api_key | 6 | = @app.api_key |
| @@ -27,5 +27,5 @@ | @@ -27,5 +27,5 @@ | ||
| 27 | %td | 27 | %td |
| 28 | %em Sadly, no one is watching this app | 28 | %em Sadly, no one is watching this app |
| 29 | 29 | ||
| 30 | -%h3 Errors | 30 | +%h3 Errs |
| 31 | = render 'errs/table', :errs => @errs | 31 | = render 'errs/table', :errs => @errs |
| 32 | \ No newline at end of file | 32 | \ No newline at end of file |
app/views/errs/_table.html.haml
| @@ -24,4 +24,4 @@ | @@ -24,4 +24,4 @@ | ||
| 24 | - if errs.none? | 24 | - if errs.none? |
| 25 | %tr | 25 | %tr |
| 26 | %td{:colspan => (@app ? 5 : 6)} | 26 | %td{:colspan => (@app ? 5 : 6)} |
| 27 | - %em No errors have been caught, yet | ||
| 28 | \ No newline at end of file | 27 | \ No newline at end of file |
| 28 | + %em No errs have been caught, yet | ||
| 29 | \ No newline at end of file | 29 | \ No newline at end of file |
app/views/errs/all.html.haml
app/views/errs/index.html.haml
| @@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
| 1 | +An err has just occurred in <%= @notice.err.environment %>: <%= @notice.err.message %> | ||
| 2 | + | ||
| 3 | +This err has occurred <%= pluralize @notice.err.notices.count, 'time' %>. You should really look into it here: | ||
| 4 | + | ||
| 5 | + <%= app_err_notice_url(@app, @notice.err, @notice) %> | ||
| 6 | + | ||
| 7 | +<%= render :partial => 'signature' %> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/views/mailer/error_notification.text.erb
| @@ -1,7 +0,0 @@ | @@ -1,7 +0,0 @@ | ||
| 1 | -An error has just occurred in <%= @notice.err.environment %>: <%= @notice.err.message %> | ||
| 2 | - | ||
| 3 | -This error has occurred <%= pluralize @notice.err.notices.count, 'time' %>. You should really look into it here: | ||
| 4 | - | ||
| 5 | - <%= app_err_notice_url(@app, @notice.err, @notice) %> | ||
| 6 | - | ||
| 7 | -<%= render :partial => 'signature' %> | ||
| 8 | \ No newline at end of file | 0 | \ No newline at end of file |
app/views/shared/_navigation.html.haml
| @@ -2,5 +2,5 @@ | @@ -2,5 +2,5 @@ | ||
| 2 | %ul | 2 | %ul |
| 3 | //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) | 3 | //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) |
| 4 | %li.apps{:class => active_if_here(:apps)}= link_to 'Apps', apps_path | 4 | %li.apps{:class => active_if_here(:apps)}= link_to 'Apps', apps_path |
| 5 | - %li.errors{:class => active_if_here(:errs)}= link_to 'Errs', errs_path | 5 | + %li.errs{:class => active_if_here(:errs)}= link_to 'Errs', errs_path |
| 6 | %div.clear | 6 | %div.clear |
| 7 | \ No newline at end of file | 7 | \ No newline at end of file |
public/stylesheets/application.css
| @@ -87,7 +87,7 @@ header #site-name { | @@ -87,7 +87,7 @@ header #site-name { | ||
| 87 | } | 87 | } |
| 88 | #nav-bar li a:hover { color: #666;} | 88 | #nav-bar li a:hover { color: #666;} |
| 89 | #nav-bar li.apps a { background-image: url(images/icons/briefcase.png); } | 89 | #nav-bar li.apps a { background-image: url(images/icons/briefcase.png); } |
| 90 | -#nav-bar li.errors a { background-image: url(images/icons/error.png); } | 90 | +#nav-bar li.errs a { background-image: url(images/icons/error.png); } |
| 91 | #nav-bar li:hover { | 91 | #nav-bar li:hover { |
| 92 | box-shadow: 0 0 3px #69c; | 92 | box-shadow: 0 0 3px #69c; |
| 93 | -moz-box-shadow: 0 0 3px #69c; | 93 | -moz-box-shadow: 0 0 3px #69c; |
spec/controllers/errs_controller_spec.rb
| @@ -6,27 +6,27 @@ describe ErrsController do | @@ -6,27 +6,27 @@ describe ErrsController do | ||
| 6 | let(:err) { Factory(:err, :app => app) } | 6 | let(:err) { Factory(:err, :app => app) } |
| 7 | 7 | ||
| 8 | describe "GET /errs" do | 8 | describe "GET /errs" do |
| 9 | - it "gets a paginated list of unresolved errors" do | ||
| 10 | - errors = WillPaginate::Collection.new(1,30) | ||
| 11 | - 3.times { errors << Factory(:err) } | 9 | + it "gets a paginated list of unresolved errs" do |
| 10 | + errs = WillPaginate::Collection.new(1,30) | ||
| 11 | + 3.times { errs << Factory(:err) } | ||
| 12 | Err.should_receive(:unresolved).and_return( | 12 | Err.should_receive(:unresolved).and_return( |
| 13 | - mock('proxy', :ordered => mock('proxy', :paginate => errors)) | 13 | + mock('proxy', :ordered => mock('proxy', :paginate => errs)) |
| 14 | ) | 14 | ) |
| 15 | get :index | 15 | get :index |
| 16 | - assigns(:errs).should == errors | 16 | + assigns(:errs).should == errs |
| 17 | end | 17 | end |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | describe "GET /errs/all" do | 20 | describe "GET /errs/all" do |
| 21 | - it "gets a paginated list of all errors" do | ||
| 22 | - errors = WillPaginate::Collection.new(1,30) | ||
| 23 | - 3.times { errors << Factory(:err) } | ||
| 24 | - 3.times { errors << Factory(:err, :resolved => true)} | 21 | + it "gets a paginated list of all errs" do |
| 22 | + errs = WillPaginate::Collection.new(1,30) | ||
| 23 | + 3.times { errs << Factory(:err) } | ||
| 24 | + 3.times { errs << Factory(:err, :resolved => true)} | ||
| 25 | Err.should_receive(:ordered).and_return( | 25 | Err.should_receive(:ordered).and_return( |
| 26 | - mock('proxy', :paginate => errors) | 26 | + mock('proxy', :paginate => errs) |
| 27 | ) | 27 | ) |
| 28 | get :index | 28 | get :index |
| 29 | - assigns(:errs).should == errors | 29 | + assigns(:errs).should == errs |
| 30 | end | 30 | end |
| 31 | end | 31 | end |
| 32 | 32 |
spec/models/err_spec.rb
| @@ -4,15 +4,15 @@ describe Err do | @@ -4,15 +4,15 @@ describe Err do | ||
| 4 | 4 | ||
| 5 | context 'validations' do | 5 | context 'validations' do |
| 6 | it 'requires a klass' do | 6 | it 'requires a klass' do |
| 7 | - error = Factory.build(:err, :klass => nil) | ||
| 8 | - error.should_not be_valid | ||
| 9 | - error.errors[:klass].should include("can't be blank") | 7 | + err = Factory.build(:err, :klass => nil) |
| 8 | + err.should_not be_valid | ||
| 9 | + err.errors[:klass].should include("can't be blank") | ||
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | it 'requires an environment' do | 12 | it 'requires an environment' do |
| 13 | - error = Factory.build(:err, :environment => nil) | ||
| 14 | - error.should_not be_valid | ||
| 15 | - error.errors[:environment].should include("can't be blank") | 13 | + err = Factory.build(:err, :environment => nil) |
| 14 | + err.should_not be_valid | ||
| 15 | + err.errors[:environment].should include("can't be blank") | ||
| 16 | end | 16 | end |
| 17 | end | 17 | end |
| 18 | 18 | ||
| @@ -28,16 +28,16 @@ describe Err do | @@ -28,16 +28,16 @@ describe Err do | ||
| 28 | } | 28 | } |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | - it 'returns the correct error if one already exists' do | 31 | + it 'returns the correct err if one already exists' do |
| 32 | existing = Err.create(@conditions) | 32 | existing = Err.create(@conditions) |
| 33 | Err.for(@conditions).should == existing | 33 | Err.for(@conditions).should == existing |
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | - it 'assigns the returned error to the given app' do | 36 | + it 'assigns the returned err to the given app' do |
| 37 | Err.for(@conditions).app.should == @app | 37 | Err.for(@conditions).app.should == @app |
| 38 | end | 38 | end |
| 39 | 39 | ||
| 40 | - it 'creates a new error if a matching one does not already exist' do | 40 | + it 'creates a new err if a matching one does not already exist' do |
| 41 | Err.where(@conditions.except(:app)).exists?.should == false | 41 | Err.where(@conditions.except(:app)).exists?.should == false |
| 42 | lambda { | 42 | lambda { |
| 43 | Err.for(@conditions) | 43 | Err.for(@conditions) |
| @@ -47,14 +47,14 @@ describe Err do | @@ -47,14 +47,14 @@ describe Err do | ||
| 47 | 47 | ||
| 48 | context '#last_notice_at' do | 48 | context '#last_notice_at' do |
| 49 | it "returns the created_at timestamp of the latest notice" do | 49 | it "returns the created_at timestamp of the latest notice" do |
| 50 | - error = Factory(:err) | ||
| 51 | - error.last_notice_at.should be_nil | 50 | + err = Factory(:err) |
| 51 | + err.last_notice_at.should be_nil | ||
| 52 | 52 | ||
| 53 | - notice1 = Factory(:notice, :err => error) | ||
| 54 | - error.last_notice_at.should == notice1.created_at | 53 | + notice1 = Factory(:notice, :err => err) |
| 54 | + err.last_notice_at.should == notice1.created_at | ||
| 55 | 55 | ||
| 56 | - notice2 = Factory(:notice, :err => error) | ||
| 57 | - error.last_notice_at.should == notice2.created_at | 56 | + notice2 = Factory(:notice, :err => err) |
| 57 | + err.last_notice_at.should == notice2.created_at | ||
| 58 | end | 58 | end |
| 59 | end | 59 | end |
| 60 | 60 | ||
| @@ -69,28 +69,28 @@ describe Err do | @@ -69,28 +69,28 @@ describe Err do | ||
| 69 | 69 | ||
| 70 | context "#resolved?" do | 70 | context "#resolved?" do |
| 71 | it "should start out as unresolved" do | 71 | it "should start out as unresolved" do |
| 72 | - error = Err.new | ||
| 73 | - error.should_not be_resolved | ||
| 74 | - error.should be_unresolved | 72 | + err = Err.new |
| 73 | + err.should_not be_resolved | ||
| 74 | + err.should be_unresolved | ||
| 75 | end | 75 | end |
| 76 | 76 | ||
| 77 | it "should be able to be resolved" do | 77 | it "should be able to be resolved" do |
| 78 | - error = Factory(:err) | ||
| 79 | - error.should_not be_resolved | ||
| 80 | - error.resolve! | ||
| 81 | - error.reload.should be_resolved | 78 | + err = Factory(:err) |
| 79 | + err.should_not be_resolved | ||
| 80 | + err.resolve! | ||
| 81 | + err.reload.should be_resolved | ||
| 82 | end | 82 | end |
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | context "resolve!" do | 85 | context "resolve!" do |
| 86 | - it "marks the error as resolved" do | 86 | + it "marks the err as resolved" do |
| 87 | err = Factory(:err) | 87 | err = Factory(:err) |
| 88 | err.should_not be_resolved | 88 | err.should_not be_resolved |
| 89 | err.resolve! | 89 | err.resolve! |
| 90 | err.should be_resolved | 90 | err.should be_resolved |
| 91 | end | 91 | end |
| 92 | 92 | ||
| 93 | - it "should throw an error if it's not successful" do | 93 | + it "should throw an err if it's not successful" do |
| 94 | err = Factory(:err) | 94 | err = Factory(:err) |
| 95 | err.should_not be_resolved | 95 | err.should_not be_resolved |
| 96 | err.klass = nil | 96 | err.klass = nil |
| @@ -103,7 +103,7 @@ describe Err do | @@ -103,7 +103,7 @@ describe Err do | ||
| 103 | 103 | ||
| 104 | context "Scopes" do | 104 | context "Scopes" do |
| 105 | context "resolved" do | 105 | context "resolved" do |
| 106 | - it 'only finds resolved Errors' do | 106 | + it 'only finds resolved Errs' do |
| 107 | resolved = Factory(:err, :resolved => true) | 107 | resolved = Factory(:err, :resolved => true) |
| 108 | unresolved = Factory(:err, :resolved => false) | 108 | unresolved = Factory(:err, :resolved => false) |
| 109 | Err.resolved.all.should include(resolved) | 109 | Err.resolved.all.should include(resolved) |
| @@ -112,7 +112,7 @@ describe Err do | @@ -112,7 +112,7 @@ describe Err do | ||
| 112 | end | 112 | end |
| 113 | 113 | ||
| 114 | context "unresolved" do | 114 | context "unresolved" do |
| 115 | - it 'only finds unresolved Errors' do | 115 | + it 'only finds unresolved Errs' do |
| 116 | resolved = Factory(:err, :resolved => true) | 116 | resolved = Factory(:err, :resolved => true) |
| 117 | unresolved = Factory(:err, :resolved => false) | 117 | unresolved = Factory(:err, :resolved => false) |
| 118 | Err.unresolved.all.should_not include(resolved) | 118 | Err.unresolved.all.should_not include(resolved) |
spec/models/notice_spec.rb
| @@ -34,7 +34,7 @@ describe Notice do | @@ -34,7 +34,7 @@ describe Notice do | ||
| 34 | @notice.err.app.should == @app | 34 | @notice.err.app.should == @app |
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | - it 'finds the correct error for the notice' do | 37 | + it 'finds the correct err for the notice' do |
| 38 | Err.should_receive(:for).with({ | 38 | Err.should_receive(:for).with({ |
| 39 | :app => @app, | 39 | :app => @app, |
| 40 | :klass => 'HoptoadTestingException', | 40 | :klass => 'HoptoadTestingException', |
| @@ -52,12 +52,12 @@ describe Notice do | @@ -52,12 +52,12 @@ describe Notice do | ||
| 52 | @notice.should be_persisted | 52 | @notice.should be_persisted |
| 53 | end | 53 | end |
| 54 | 54 | ||
| 55 | - it 'assigns an error to the notice' do | 55 | + it 'assigns an err to the notice' do |
| 56 | @notice = Notice.from_xml(@xml) | 56 | @notice = Notice.from_xml(@xml) |
| 57 | @notice.err.should be_a(Err) | 57 | @notice.err.should be_a(Err) |
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | - it 'captures the error message' do | 60 | + it 'captures the err message' do |
| 61 | @notice = Notice.from_xml(@xml) | 61 | @notice = Notice.from_xml(@xml) |
| 62 | @notice.message.should == 'HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works.' | 62 | @notice.message.should == 'HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works.' |
| 63 | end | 63 | end |
| @@ -88,15 +88,15 @@ describe Notice do | @@ -88,15 +88,15 @@ describe Notice do | ||
| 88 | describe "email notifications" do | 88 | describe "email notifications" do |
| 89 | before do | 89 | before do |
| 90 | @app = Factory(:app_with_watcher) | 90 | @app = Factory(:app_with_watcher) |
| 91 | - @error = Factory(:err, :app => @app) | 91 | + @err = Factory(:err, :app => @app) |
| 92 | end | 92 | end |
| 93 | 93 | ||
| 94 | Errbit::Config.email_at_notices.each do |threshold| | 94 | Errbit::Config.email_at_notices.each do |threshold| |
| 95 | it "sends an email notification after #{threshold} notice(s)" do | 95 | it "sends an email notification after #{threshold} notice(s)" do |
| 96 | - @error.notices.stub(:count).and_return(threshold) | ||
| 97 | - Mailer.should_receive(:error_notification). | 96 | + @err.notices.stub(:count).and_return(threshold) |
| 97 | + Mailer.should_receive(:err_notification). | ||
| 98 | and_return(mock('email', :deliver => true)) | 98 | and_return(mock('email', :deliver => true)) |
| 99 | - Factory(:notice, :err => @error) | 99 | + Factory(:notice, :err => @err) |
| 100 | end | 100 | end |
| 101 | end | 101 | end |
| 102 | end | 102 | end |