diff --git a/app/models/app.rb b/app/models/app.rb index 8e80221..e088126 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -124,7 +124,11 @@ class App end def notification_recipients - notify_all_users ? User.all.map(&:email).reject(&:blank?) : watchers.map(&:address) + if notify_all_users + (User.all.map(&:email).reject(&:blank?) + watchers.map(&:address)).uniq + else + watchers.map(&:address) + end end # Copy app attributes from another app. diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml index b14a65d..e37f013 100644 --- a/app/views/apps/_fields.html.haml +++ b/app/views/apps/_fields.html.haml @@ -23,7 +23,7 @@ = f.label :notify_on_deploys, 'Notify on deploys' %div.checkbox - = f.check_box :notify_all_users, 'data-hide-when-checked' => '.watchers.nested-wrapper' + = f.check_box :notify_all_users = f.label :notify_all_users, 'Send notifications to all users' diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 4b7effd..5a4e5ea 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -88,12 +88,12 @@ describe App do end context "notification recipients" do - it "should send notices to either all users, or the configured watchers" do + it "should send notices to either all users plus watchers, or the configured watchers" do @app = Fabricate(:app) 3.times { Fabricate(:user) } 5.times { Fabricate(:watcher, :app => @app) } @app.notify_all_users = true - @app.notification_recipients.size.should == 3 + @app.notification_recipients.size.should == 8 @app.notify_all_users = false @app.notification_recipients.size.should == 5 end -- libgit2 0.21.2