From 70bcab3abc2b2ee82d328370cc651fa35802711f Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 15 Nov 2010 15:27:38 -0800 Subject: [PATCH] adding a couple specs to invitation_spec --- spec/models/invitation_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index ce8e6584d..e5843a7c3 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -10,6 +10,7 @@ describe Invitation do let(:user2) {make_user} before do @email = 'maggie@example.com' + Devise.mailer.deliveries = [] end describe 'validations' do before do @@ -78,6 +79,11 @@ describe Invitation do new_user.invitations_to_me.first.message.should == message end + it 'mails the optional message' do + message = "How've you been?" + new_user = Invitation.invite(:from => user, :email => @email, :into => aspect, :message => message) + Devise.mailer.deliveries.first.to_s.include?(message).should be_true + end it 'sends a contact request to a user with that email into the aspect' do user2 user.should_receive(:send_contact_request_to){ |a, b| @@ -100,10 +106,15 @@ describe Invitation do }.should change{Devise.mailer.deliveries.size}.by(1) end it 'sends an email that includes the right things' do - Devise.mailer.deliveries = [] Invitation.create_invitee(:email => @email) Devise.mailer.deliveries.first.to_s.include?("Welcome #{@email}").should == true end + context 'with no inviter' do + it 'does not render nonsensical emails' do + Invitation.create_invitee(:email => @email) + Devise.mailer.deliveries.first.subject.match(/a friend/i).should be_false + end + end end describe '#to_request!' do