Commit 13a85a2127d0a9c74f4e5cc5904f5c49ba4b008e
1 parent
cccdfbdc
Exists in
master
and in
1 other branch
Add a watcher address that will be the user's email or the email listed on the w…
…atcher. Send to this address.
Showing
3 changed files
with
18 additions
and
3 deletions
Show diff stats
app/mailers/mailer.rb
| ... | ... | @@ -6,7 +6,7 @@ class Mailer < ActionMailer::Base |
| 6 | 6 | @app = notice.err.app |
| 7 | 7 | |
| 8 | 8 | mail({ |
| 9 | - :to => @app.watchers.map(&:email), | |
| 9 | + :to => @app.watchers.map(&:address), | |
| 10 | 10 | :subject => "[#{@app.name}] #{@notice.err.message}" |
| 11 | 11 | }) |
| 12 | 12 | end |
| ... | ... | @@ -16,7 +16,7 @@ class Mailer < ActionMailer::Base |
| 16 | 16 | @app = deploy.app |
| 17 | 17 | |
| 18 | 18 | mail({ |
| 19 | - :to => @app.watchers.map(&:email), | |
| 19 | + :to => @app.watchers.map(&:address), | |
| 20 | 20 | :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" |
| 21 | 21 | }) |
| 22 | 22 | end | ... | ... |
app/models/watcher.rb
spec/models/watcher_spec.rb
| ... | ... | @@ -17,8 +17,19 @@ describe Watcher do |
| 17 | 17 | watcher.user = Factory(:user) |
| 18 | 18 | watcher.should be_valid |
| 19 | 19 | end |
| 20 | + end | |
| 21 | + | |
| 22 | + context 'address' do | |
| 23 | + it "returns the user's email address if there is a user" do | |
| 24 | + user = Factory(:user, :email => 'foo@bar.com') | |
| 25 | + watcher = Factory(:watcher, :user => user) | |
| 26 | + watcher.address.should == 'foo@bar.com' | |
| 27 | + end | |
| 20 | 28 | |
| 21 | - | |
| 29 | + it "returns the email if there is no user" do | |
| 30 | + watcher = Factory(:watcher, :email => 'widgets@acme.com', :user => nil) | |
| 31 | + watcher.address.should == 'widgets@acme.com' | |
| 32 | + end | |
| 22 | 33 | end |
| 23 | 34 | |
| 24 | 35 | end | ... | ... |