Commit 1c1a0322e36b3f8be47f937574f684f39b502462
1 parent
06fd017e
Exists in
master
and in
1 other branch
Keeping ability to setup email frequency globally.
Showing
7 changed files
with
15 additions
and
16 deletions
Show diff stats
app/controllers/apps_controller.rb
... | ... | @@ -85,7 +85,7 @@ class AppsController < ApplicationController |
85 | 85 | if email_at_notices.any? |
86 | 86 | params[:app][:email_at_notices] = email_at_notices |
87 | 87 | else |
88 | - default_array = params[:app][:email_at_notices] = Errbit::Config.default_email_at_notices | |
88 | + default_array = params[:app][:email_at_notices] = Errbit::Config.email_at_notices | |
89 | 89 | flash[:error] = "Couldn't parse your notification frequency. Value was reset to default (#{default_array.join(', ')})." |
90 | 90 | end |
91 | 91 | end | ... | ... |
app/models/app.rb
... | ... | @@ -8,7 +8,7 @@ class App |
8 | 8 | field :resolve_errs_on_deploy, :type => Boolean, :default => false |
9 | 9 | field :notify_on_errs, :type => Boolean, :default => true |
10 | 10 | field :notify_on_deploys, :type => Boolean, :default => true |
11 | - field :email_at_notices, :type => Array, :default => Errbit::Config.default_email_at_notices | |
11 | + field :email_at_notices, :type => Array, :default => Errbit::Config.email_at_notices | |
12 | 12 | |
13 | 13 | # Some legacy apps may have sting as key instead of BSON::ObjectID |
14 | 14 | identity :type => String | ... | ... |
app/views/apps/_fields.html.haml
... | ... | @@ -13,11 +13,11 @@ |
13 | 13 | %div.checkbox |
14 | 14 | = f.check_box :notify_on_errs |
15 | 15 | = f.label :notify_on_errs, 'Notify on errors' |
16 | - %div.email_at_notices_nested{:style => f.object.notify_on_errs ? '' : 'display: none;'} | |
17 | - .field-helpertext Send a notification every | |
18 | - -# Edit the email_at_notices array as a CSV string | |
19 | - = f.text_field :email_at_notices, :value => f.object.email_at_notices.join(", ") | |
20 | - .field-helpertext times an error occurs. (CSV) | |
16 | + - if Errbit::Config.per_app_email_at_notices | |
17 | + %div.email_at_notices_nested{:style => f.object.notify_on_errs ? '' : 'display: none;'} | |
18 | + .field-helpertext Send a notification every | |
19 | + = f.text_field :email_at_notices, :value => f.object.email_at_notices.join(", ") | |
20 | + .field-helpertext times an error occurs (comma separated). | |
21 | 21 | %div.checkbox |
22 | 22 | = f.check_box :notify_on_deploys |
23 | 23 | = f.label :notify_on_deploys, 'Notify on deploys' | ... | ... |
config/config.example.yml
... | ... | @@ -14,13 +14,13 @@ host: errbit.example.com |
14 | 14 | # will be sent from. |
15 | 15 | email_from: errbit@example.com |
16 | 16 | |
17 | -# Configure the default value for when emails are sent for an error. | |
17 | +# if you turn on this option, email_at_notices will be configured on per app basis | |
18 | +# at App edit page | |
19 | +per_app_email_at_notices: false | |
20 | + | |
21 | +# Configure when emails are sent for an error. | |
18 | 22 | # [1,3,7] = 1st, 3rd, and 7th occurence triggers |
19 | 23 | # an email notification. |
20 | -# Each app can be configured individually. | |
21 | -default_email_at_notices: [1, 10, 100] | |
24 | +email_at_notices: [1, 10, 100] | |
22 | 25 | |
23 | -# Set to false to suppress confirmation when | |
24 | -# resolving errors. | |
25 | 26 | confirm_resolve_err: true |
26 | - | ... | ... |
config/initializers/_load_config.rb
... | ... | @@ -4,7 +4,7 @@ if ENV['HEROKU'] |
4 | 4 | Errbit::Config = OpenStruct.new |
5 | 5 | Errbit::Config.host = ENV['ERRBIT_HOST'] |
6 | 6 | Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] |
7 | - Errbit::Config.default_email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES'] | |
7 | + Errbit::Config.email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES'] | |
8 | 8 | Errbit::Application.config.action_mailer.smtp_settings = { |
9 | 9 | :address => "smtp.sendgrid.net", |
10 | 10 | :port => "25", | ... | ... |
spec/controllers/apps_controller_spec.rb
... | ... | @@ -252,7 +252,7 @@ describe AppsController do |
252 | 252 | @app = Factory(:app, :email_at_notices => [1, 2, 3, 4]) |
253 | 253 | put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } |
254 | 254 | @app.reload |
255 | - @app.email_at_notices.should == Errbit::Config.default_email_at_notices | |
255 | + @app.email_at_notices.should == Errbit::Config.email_at_notices | |
256 | 256 | end |
257 | 257 | |
258 | 258 | it "should display a message" do | ... | ... |