diff --git a/app/models/invite_request.rb b/app/models/invite_request.rb index d17857cc2f..e78702db65 100644 --- a/app/models/invite_request.rb +++ b/app/models/invite_request.rb @@ -53,8 +53,7 @@ def compare_with_users def invite_and_remove(creator=nil) invitation = creator ? creator.invitations.build(invitee_email: self.email, from_queue: true) : Invitation.new(invitee_email: self.email, from_queue: true) - if invitation.save - self.destroy - end + invitation.save + self.destroy end end diff --git a/features/other_a/invite_queue.feature b/features/other_a/invite_queue.feature index dea9800bd8..fc58e39e01 100644 --- a/features/other_a/invite_queue.feature +++ b/features/other_a/invite_queue.feature @@ -181,3 +181,20 @@ Feature: Invite queue management When I press "Resend Invitation" Then 1 email should be delivered to invitee@example.org + + Scenario: Invitation requests don't get stuck in the queue if a user changes their email to the requests' email + Given account creation is enabled + And the invitation queue is enabled + And account creation requires an invitation + And the invite_from_queue_at is yesterday + And an invitation request for "test@archiveofourown.org" + And the following activated users exist + | login | email | + | fred | nottest@archiveofourown.org | + When I am logged in as "fred" + And I change my email to "test@archiveofourown.org" + And all emails have been delivered + And the scheduled check_invite_queue job is run + And I go to the invite_requests page + Then I should see "There are currently 0 people on the waiting list" + And 0 emails should be delivered to test@archiveofourown.org