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 | class DeploysController < ApplicationController | 1 | class DeploysController < ApplicationController |
| 2 | + | ||
| 3 | + protect_from_forgery :except => :create | ||
| 2 | 4 | ||
| 3 | skip_before_filter :verify_authenticity_token, :only => :create | 5 | skip_before_filter :verify_authenticity_token, :only => :create |
| 4 | skip_before_filter :authenticate_user!, :only => :create | 6 | skip_before_filter :authenticate_user!, :only => :create |
| @@ -11,6 +13,7 @@ class DeploysController < ApplicationController | @@ -11,6 +13,7 @@ class DeploysController < ApplicationController | ||
| 11 | :environment => params[:deploy][:rails_env], | 13 | :environment => params[:deploy][:rails_env], |
| 12 | :repository => params[:deploy][:scm_repository], | 14 | :repository => params[:deploy][:scm_repository], |
| 13 | :revision => params[:deploy][:scm_revision], | 15 | :revision => params[:deploy][:scm_revision], |
| 16 | + :message => params[:deploy][:message] | ||
| 14 | } | 17 | } |
| 15 | end | 18 | end |
| 16 | 19 |
app/models/app.rb
| @@ -5,6 +5,9 @@ class App | @@ -5,6 +5,9 @@ class App | ||
| 5 | field :name, :type => String | 5 | field :name, :type => String |
| 6 | field :api_key | 6 | field :api_key |
| 7 | field :resolve_errs_on_deploy, :type => Boolean, :default => false | 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 | # Some legacy apps may have sting as key instead of BSON::ObjectID | 11 | # Some legacy apps may have sting as key instead of BSON::ObjectID |
| 9 | identity :type => String | 12 | identity :type => String |
| 10 | # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature: | 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 +6,7 @@ class Deploy | ||
| 6 | field :repository | 6 | field :repository |
| 7 | field :environment | 7 | field :environment |
| 8 | field :revision | 8 | field :revision |
| 9 | + field :message | ||
| 9 | 10 | ||
| 10 | index :created_at, Mongo::DESCENDING | 11 | index :created_at, Mongo::DESCENDING |
| 11 | 12 | ||
| @@ -27,7 +28,7 @@ class Deploy | @@ -27,7 +28,7 @@ class Deploy | ||
| 27 | protected | 28 | protected |
| 28 | 29 | ||
| 29 | def should_notify? | 30 | def should_notify? |
| 30 | - app.watchers.any? | 31 | + app.notify_on_deploys? && app.watchers.any? |
| 31 | end | 32 | end |
| 32 | 33 | ||
| 33 | def should_resolve_app_errs? | 34 | def should_resolve_app_errs? |
app/models/err.rb
| @@ -12,6 +12,7 @@ class Err | @@ -12,6 +12,7 @@ class Err | ||
| 12 | field :issue_link, :type => String | 12 | field :issue_link, :type => String |
| 13 | 13 | ||
| 14 | index :last_notice_at | 14 | index :last_notice_at |
| 15 | + index :app_id | ||
| 15 | 16 | ||
| 16 | referenced_in :app | 17 | referenced_in :app |
| 17 | embeds_many :notices | 18 | embeds_many :notices |
app/models/notice.rb
| @@ -73,7 +73,7 @@ class Notice | @@ -73,7 +73,7 @@ class Notice | ||
| 73 | protected | 73 | protected |
| 74 | 74 | ||
| 75 | def should_notify? | 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 | end | 77 | end |
| 78 | 78 | ||
| 79 | end | 79 | end |
| 80 | \ No newline at end of file | 80 | \ No newline at end of file |
app/views/apps/_fields.html.haml
| @@ -5,9 +5,17 @@ | @@ -5,9 +5,17 @@ | ||
| 5 | = f.text_field :name | 5 | = f.text_field :name |
| 6 | 6 | ||
| 7 | %div.checkbox | 7 | %div.checkbox |
| 8 | + = f.check_box :notify_on_errs | ||
| 9 | + = f.label :notify_on_errs, 'Notify on errors' | ||
| 10 | + | ||
| 11 | +%div.checkbox | ||
| 8 | = f.check_box :resolve_errs_on_deploy | 12 | = f.check_box :resolve_errs_on_deploy |
| 9 | = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' | 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 | %fieldset.nested-wrapper | 19 | %fieldset.nested-wrapper |
| 12 | %legend Watchers | 20 | %legend Watchers |
| 13 | = f.fields_for :watchers do |w| | 21 | = f.fields_for :watchers do |w| |
app/views/apps/show.html.haml
| @@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
| 34 | %tr | 34 | %tr |
| 35 | %th When | 35 | %th When |
| 36 | %th Who | 36 | %th Who |
| 37 | + %th Message | ||
| 37 | %th Repository | 38 | %th Repository |
| 38 | %th Revision | 39 | %th Revision |
| 39 | 40 | ||
| @@ -42,6 +43,7 @@ | @@ -42,6 +43,7 @@ | ||
| 42 | %tr | 43 | %tr |
| 43 | %td.when #{deploy.created_at.to_s(:micro)} | 44 | %td.when #{deploy.created_at.to_s(:micro)} |
| 44 | %td.who #{deploy.username} | 45 | %td.who #{deploy.username} |
| 46 | + %td.message #{deploy.message} | ||
| 45 | %td.repository #{deploy.repository} | 47 | %td.repository #{deploy.repository} |
| 46 | %td.revision #{deploy.revision} | 48 | %td.revision #{deploy.revision} |
| 47 | = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button' | 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,6 +4,7 @@ | ||
| 4 | %th App | 4 | %th App |
| 5 | %th When | 5 | %th When |
| 6 | %th Who | 6 | %th Who |
| 7 | + %th Message | ||
| 7 | %th Repository | 8 | %th Repository |
| 8 | %th Revision | 9 | %th Revision |
| 9 | %tbody | 10 | %tbody |
| @@ -14,5 +15,6 @@ | @@ -14,5 +15,6 @@ | ||
| 14 | %span.environment= deploy.environment | 15 | %span.environment= deploy.environment |
| 15 | %td.latest #{time_ago_in_words(deploy.created_at)} ago | 16 | %td.latest #{time_ago_in_words(deploy.created_at)} ago |
| 16 | %td.who #{deploy.username} | 17 | %td.who #{deploy.username} |
| 18 | + %td.message #{deploy.message} | ||
| 17 | %td.repository #{deploy.repository} | 19 | %td.repository #{deploy.repository} |
| 18 | %td.revision #{deploy.revision} | 20 | %td.revision #{deploy.revision} |
spec/controllers/deploys_controller_spec.rb
| @@ -9,7 +9,8 @@ describe DeploysController do | @@ -9,7 +9,8 @@ describe DeploysController do | ||
| 9 | 'local_username' => 'john.doe', | 9 | 'local_username' => 'john.doe', |
| 10 | 'scm_repository' => 'git@github.com/jdpace/errbit.git', | 10 | 'scm_repository' => 'git@github.com/jdpace/errbit.git', |
| 11 | 'rails_env' => 'production', | 11 | 'rails_env' => 'production', |
| 12 | - 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5' | 12 | + 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
| 13 | + 'message' => 'johns first deploy' | ||
| 13 | } | 14 | } |
| 14 | @app = Factory(:app_with_watcher, :api_key => 'APIKEY') | 15 | @app = Factory(:app_with_watcher, :api_key => 'APIKEY') |
| 15 | end | 16 | end |
| @@ -26,7 +27,9 @@ describe DeploysController do | @@ -26,7 +27,9 @@ describe DeploysController do | ||
| 26 | :username => 'john.doe', | 27 | :username => 'john.doe', |
| 27 | :environment => 'production', | 28 | :environment => 'production', |
| 28 | :repository => 'git@github.com/jdpace/errbit.git', | 29 | :repository => 'git@github.com/jdpace/errbit.git', |
| 29 | - :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5' | 30 | + :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
| 31 | + :message => 'johns first deploy' | ||
| 32 | + | ||
| 30 | }).and_return(Factory(:deploy)) | 33 | }).and_return(Factory(:deploy)) |
| 31 | post :create, :deploy => @params, :api_key => 'APIKEY' | 34 | post :create, :deploy => @params, :api_key => 'APIKEY' |
| 32 | end | 35 | end |
spec/models/deploy_spec.rb
| @@ -42,6 +42,13 @@ describe Deploy do | @@ -42,6 +42,13 @@ describe Deploy do | ||
| 42 | @staging_errs.all?{|err| err.reload.resolved?}.should == false | 42 | @staging_errs.all?{|err| err.reload.resolved?}.should == false |
| 43 | end | 43 | end |
| 44 | end | 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 | end | 52 | end |
| 46 | 53 | ||
| 47 | end | 54 | end |
spec/models/err_spec.rb
| @@ -120,5 +120,14 @@ describe Err do | @@ -120,5 +120,14 @@ describe Err do | ||
| 120 | end | 120 | end |
| 121 | end | 121 | end |
| 122 | end | 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 | end | 133 | end |
| 125 | \ No newline at end of file | 134 | \ No newline at end of file |