File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ def to_param
1515 end
1616
1717 def deliver
18- EmailInviter . new ( self ) . deliver
18+ body = InvitationMessage . new ( self ) . body
19+ Mailer . invitation_notification ( self , body ) . deliver
1920 end
2021
2122 private
Original file line number Diff line number Diff line change 1313end
1414
1515describe Invitation , '#deliver' do
16+ include Rails . application . routes . url_helpers
17+ self . default_url_options = ActionMailer ::Base . default_url_options
18+
1619 it 'sends email notifications to new users' do
17- inviter = stub ( 'inviter' , deliver : true )
18- EmailInviter . stubs ( new : inviter )
19- invitation = build_stubbed ( :invitation )
20+ survey = create ( :survey )
21+ invitation = create ( :invitation , message : 'hello' , survey : survey )
2022
2123 invitation . deliver
2224
23- EmailInviter . should have_received ( :new ) . with ( invitation )
24- inviter . should have_received ( :deliver )
25+ message = ActionMailer ::Base . deliveries . last
26+ message . should deliver_to ( invitation . recipient_email )
27+ message . should have_body_text ( invitation . sender . email )
28+ message . should have_body_text ( invitation . message )
29+ message . should have_body_text ( survey_url ( survey ) )
2530 end
2631end
2732
You can’t perform that action at this time.
0 commit comments