FIX: update timestamp when resending invite

This commit is contained in:
Arpit Jalan 2017-04-11 19:35:35 +05:30
parent 5a57278a8e
commit 8fb41bf5fb
2 changed files with 10 additions and 1 deletions

View File

@ -116,6 +116,8 @@ class Invite < ActiveRecord::Base
invite = nil
end
invite.update_columns(created_at: Time.zone.now, updated_at: Time.zone.now) if invite
if !invite
create_args = { invited_by: invited_by, email: lower_email }
create_args[:moderator] = true if opts[:moderator]

View File

@ -102,8 +102,15 @@ describe Invite do
expect(topic.invite_by_email(inviter, 'ICEKING@adventuretime.ooo')).to eq(@invite)
end
it 'updates timestamp of existing invite' do
@invite.created_at = 10.days.ago
@invite.save
resend_invite = topic.invite_by_email(inviter, 'iceking@adventuretime.ooo')
expect(resend_invite.created_at).to be_within(1.minute).of(Time.zone.now)
end
it 'returns a new invite if the other has expired' do
SiteSetting.stubs(:invite_expiry_days).returns(1)
SiteSetting.invite_expiry_days = 1
@invite.created_at = 2.days.ago
@invite.save
new_invite = topic.invite_by_email(inviter, 'iceking@adventuretime.ooo')