Add tests for redeem invite feature
This commit is contained in:
parent
b301391116
commit
caf8dbe92f
|
@ -349,4 +349,24 @@ describe Invite do
|
||||||
result.should be_valid
|
result.should be_valid
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue