File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class Notification < ActionMailer ::Base
2+ default from : "steve@hackety.com"
3+ default_url_options [ :host ] = "example.com"
4+
5+ def new_answer ( question )
6+ @question = question
7+ @url = question_url ( question , :host => "hackety.com" )
8+ mail ( :to => question . user . email , :subject => "New Answer on Hackety.com!" )
9+ end
10+ end
Original file line number Diff line number Diff line change 1+ Hey there! You asked a question on Hackety.com: ""
2+
3+ Someone has replied with an answer! Check it out here: #{@url}
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Notification do
4+ describe "new_answer" do
5+ let ( :question ) { Fabricate ( :question ) }
6+ let ( :mail ) { Notification . new_answer ( question ) }
7+
8+ it "has a link to the question" do
9+ mail . body . encoded . should match ( question_url ( question , :host => "hackety.com" ) )
10+ end
11+
12+ it "is from Steve" do
13+ mail . from . should eq ( [ "steve@hackety.com" ] )
14+ end
15+
16+ it "is to the question's author" do
17+ mail . to . should eq ( [ question . user . email ] )
18+ end
19+
20+ it "has the proper subject" do
21+ mail . subject . should eq ( "New Answer on Hackety.com!" )
22+ end
23+ end
24+ end
Original file line number Diff line number Diff line change 2323 config . before ( :each ) do
2424 DatabaseCleaner [ :mongo_mapper ] . clean
2525 end
26+
27+ config . include ( MailerMacros )
28+ config . before ( :each ) { reset_email }
2629end
Original file line number Diff line number Diff line change 1+ module MailerMacros
2+ def last_email
3+ ActionMailer ::Base . deliveries . last
4+ end
5+
6+ def reset_email
7+ ActionMailer ::Base . deliveries = [ ]
8+ end
9+ end
10+
You can’t perform that action at this time.
0 commit comments