diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index 5e936aca8..82704203f 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -349,4 +349,24 @@ describe Invite do result.should be_valid end end + + describe '.redeem_from_email' do + let(:inviter) { Fabricate(:user) } + let(:invite) { Fabricate(:invite, invited_by: inviter, email: 'test@example.com', user_id: nil) } + let(:user) { Fabricate(:user, email: invite.email) } + + it 'redeems the invite from email' do + result = Invite.redeem_from_email(user.email) + invite.reload + invite.should be_redeemed + end + + it 'does not redeem the invite if email does not match' do + result = Invite.redeem_from_email('test24@example.com') + invite.reload + invite.should_not be_redeemed + end + + end + end