adding a couple specs to invitation_spec

This commit is contained in:
Raphael 2010-11-15 15:27:38 -08:00
parent eb8b35f222
commit 70bcab3abc

View file

@ -10,6 +10,7 @@ describe Invitation do
let(:user2) {make_user} let(:user2) {make_user}
before do before do
@email = 'maggie@example.com' @email = 'maggie@example.com'
Devise.mailer.deliveries = []
end end
describe 'validations' do describe 'validations' do
before do before do
@ -78,6 +79,11 @@ describe Invitation do
new_user.invitations_to_me.first.message.should == message new_user.invitations_to_me.first.message.should == message
end 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 it 'sends a contact request to a user with that email into the aspect' do
user2 user2
user.should_receive(:send_contact_request_to){ |a, b| user.should_receive(:send_contact_request_to){ |a, b|
@ -100,10 +106,15 @@ describe Invitation do
}.should change{Devise.mailer.deliveries.size}.by(1) }.should change{Devise.mailer.deliveries.size}.by(1)
end end
it 'sends an email that includes the right things' do it 'sends an email that includes the right things' do
Devise.mailer.deliveries = []
Invitation.create_invitee(:email => @email) Invitation.create_invitee(:email => @email)
Devise.mailer.deliveries.first.to_s.include?("Welcome #{@email}").should == true Devise.mailer.deliveries.first.to_s.include?("Welcome #{@email}").should == true
end 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 end
describe '#to_request!' do describe '#to_request!' do