Commit fb68c4e935aad6103b80cc590a27349c5ce565d2
Exists in
master
and in
1 other branch
Merge branch 'master' of https://github.com/unkopro/errbit into unkopro-master
Conflicts: app/controllers/deploys_controller.rb app/models/app.rb
Showing
11 changed files
with
45 additions
and
6 deletions
Show diff stats
app/controllers/deploys_controller.rb
| 1 | 1 | class DeploysController < ApplicationController |
| 2 | + | |
| 3 | + protect_from_forgery :except => :create | |
| 2 | 4 | |
| 3 | 5 | skip_before_filter :verify_authenticity_token, :only => :create |
| 4 | 6 | skip_before_filter :authenticate_user!, :only => :create |
| ... | ... | @@ -11,6 +13,7 @@ class DeploysController < ApplicationController |
| 11 | 13 | :environment => params[:deploy][:rails_env], |
| 12 | 14 | :repository => params[:deploy][:scm_repository], |
| 13 | 15 | :revision => params[:deploy][:scm_revision], |
| 16 | + :message => params[:deploy][:message] | |
| 14 | 17 | } |
| 15 | 18 | end |
| 16 | 19 | ... | ... |
app/models/app.rb
| ... | ... | @@ -5,6 +5,9 @@ class App |
| 5 | 5 | field :name, :type => String |
| 6 | 6 | field :api_key |
| 7 | 7 | field :resolve_errs_on_deploy, :type => Boolean, :default => false |
| 8 | + field :notify_on_errs, :type => Boolean, :default => true | |
| 9 | + field :notify_on_deploys, :type => Boolean, :default => true | |
| 10 | + | |
| 8 | 11 | # Some legacy apps may have sting as key instead of BSON::ObjectID |
| 9 | 12 | identity :type => String |
| 10 | 13 | # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature: | ... | ... |
app/models/deploy.rb
| ... | ... | @@ -6,6 +6,7 @@ class Deploy |
| 6 | 6 | field :repository |
| 7 | 7 | field :environment |
| 8 | 8 | field :revision |
| 9 | + field :message | |
| 9 | 10 | |
| 10 | 11 | index :created_at, Mongo::DESCENDING |
| 11 | 12 | |
| ... | ... | @@ -27,7 +28,7 @@ class Deploy |
| 27 | 28 | protected |
| 28 | 29 | |
| 29 | 30 | def should_notify? |
| 30 | - app.watchers.any? | |
| 31 | + app.notify_on_deploys? && app.watchers.any? | |
| 31 | 32 | end |
| 32 | 33 | |
| 33 | 34 | def should_resolve_app_errs? | ... | ... |
app/models/err.rb
app/models/notice.rb
| ... | ... | @@ -73,7 +73,7 @@ class Notice |
| 73 | 73 | protected |
| 74 | 74 | |
| 75 | 75 | def should_notify? |
| 76 | - Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? | |
| 76 | + err.app.notify_on_errs? && Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? | |
| 77 | 77 | end |
| 78 | 78 | |
| 79 | 79 | end |
| 80 | 80 | \ No newline at end of file | ... | ... |
app/views/apps/_fields.html.haml
| ... | ... | @@ -5,9 +5,17 @@ |
| 5 | 5 | = f.text_field :name |
| 6 | 6 | |
| 7 | 7 | %div.checkbox |
| 8 | + = f.check_box :notify_on_errs | |
| 9 | + = f.label :notify_on_errs, 'Notify on errors' | |
| 10 | + | |
| 11 | +%div.checkbox | |
| 8 | 12 | = f.check_box :resolve_errs_on_deploy |
| 9 | 13 | = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' |
| 10 | - | |
| 14 | + | |
| 15 | +%div.checkbox | |
| 16 | + = f.check_box :notify_on_deploys | |
| 17 | + = f.label :notify_on_deploys, 'Notify on deploys' | |
| 18 | + | |
| 11 | 19 | %fieldset.nested-wrapper |
| 12 | 20 | %legend Watchers |
| 13 | 21 | = f.fields_for :watchers do |w| | ... | ... |
app/views/apps/show.html.haml
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | %tr |
| 35 | 35 | %th When |
| 36 | 36 | %th Who |
| 37 | + %th Message | |
| 37 | 38 | %th Repository |
| 38 | 39 | %th Revision |
| 39 | 40 | |
| ... | ... | @@ -42,6 +43,7 @@ |
| 42 | 43 | %tr |
| 43 | 44 | %td.when #{deploy.created_at.to_s(:micro)} |
| 44 | 45 | %td.who #{deploy.username} |
| 46 | + %td.message #{deploy.message} | |
| 45 | 47 | %td.repository #{deploy.repository} |
| 46 | 48 | %td.revision #{deploy.revision} |
| 47 | 49 | = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button' | ... | ... |
app/views/deploys/_table.html.haml
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | %th App |
| 5 | 5 | %th When |
| 6 | 6 | %th Who |
| 7 | + %th Message | |
| 7 | 8 | %th Repository |
| 8 | 9 | %th Revision |
| 9 | 10 | %tbody |
| ... | ... | @@ -14,5 +15,6 @@ |
| 14 | 15 | %span.environment= deploy.environment |
| 15 | 16 | %td.latest #{time_ago_in_words(deploy.created_at)} ago |
| 16 | 17 | %td.who #{deploy.username} |
| 18 | + %td.message #{deploy.message} | |
| 17 | 19 | %td.repository #{deploy.repository} |
| 18 | 20 | %td.revision #{deploy.revision} | ... | ... |
spec/controllers/deploys_controller_spec.rb
| ... | ... | @@ -9,7 +9,8 @@ describe DeploysController do |
| 9 | 9 | 'local_username' => 'john.doe', |
| 10 | 10 | 'scm_repository' => 'git@github.com/jdpace/errbit.git', |
| 11 | 11 | 'rails_env' => 'production', |
| 12 | - 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5' | |
| 12 | + 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | |
| 13 | + 'message' => 'johns first deploy' | |
| 13 | 14 | } |
| 14 | 15 | @app = Factory(:app_with_watcher, :api_key => 'APIKEY') |
| 15 | 16 | end |
| ... | ... | @@ -26,7 +27,9 @@ describe DeploysController do |
| 26 | 27 | :username => 'john.doe', |
| 27 | 28 | :environment => 'production', |
| 28 | 29 | :repository => 'git@github.com/jdpace/errbit.git', |
| 29 | - :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5' | |
| 30 | + :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | |
| 31 | + :message => 'johns first deploy' | |
| 32 | + | |
| 30 | 33 | }).and_return(Factory(:deploy)) |
| 31 | 34 | post :create, :deploy => @params, :api_key => 'APIKEY' |
| 32 | 35 | end | ... | ... |
spec/models/deploy_spec.rb
| ... | ... | @@ -42,6 +42,13 @@ describe Deploy do |
| 42 | 42 | @staging_errs.all?{|err| err.reload.resolved?}.should == false |
| 43 | 43 | end |
| 44 | 44 | end |
| 45 | + | |
| 46 | + context 'when the app has deploy notifications set to false' do | |
| 47 | + it 'should not send an email notification' do | |
| 48 | + Mailer.should_not_receive(:deploy_notification) | |
| 49 | + Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => false)) | |
| 50 | + end | |
| 51 | + end | |
| 45 | 52 | end |
| 46 | 53 | |
| 47 | 54 | end | ... | ... |
spec/models/err_spec.rb
| ... | ... | @@ -120,5 +120,14 @@ describe Err do |
| 120 | 120 | end |
| 121 | 121 | end |
| 122 | 122 | end |
| 123 | - | |
| 123 | + | |
| 124 | + context 'being created' do | |
| 125 | + context 'when the app has err notifications set to false' do | |
| 126 | + it 'should not send an email notification' do | |
| 127 | + app = Factory(:app_with_watcher, :notify_on_errs => false) | |
| 128 | + Mailer.should_not_receive(:err_notification) | |
| 129 | + Factory(:err, :app => app) | |
| 130 | + end | |
| 131 | + end | |
| 132 | + end | |
| 124 | 133 | end |
| 125 | 134 | \ No newline at end of file | ... | ... |