Skip to content

Commit 84476c8

Browse files
committed
[5432] Skip existing user email vailidation for account requests that are rejected or closed by admin
1 parent bda56a6 commit 84476c8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/models/account_request.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def email_not_already_used_by_organization
9494
end
9595

9696
def email_not_already_used_by_user
97+
return if rejected? || admin_closed?
9798
user = User.find_by(email: email)
9899
if user && (!organization || user.organization_id != organization.id)
99100
errors.add(:email, 'already used by an existing User')

spec/models/account_request_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
expect(subject.valid?).to eq(false)
6262
expect(subject.errors.messages[:email]).to match_array(["already used by an existing User"])
6363
end
64+
65+
[:rejected, :admin_closed].each do |status|
66+
context "when the status is #{status}" do
67+
before { subject.status = status }
68+
69+
it 'allows the email' do
70+
expect(subject).to be_valid
71+
end
72+
end
73+
end
6474
end
6575
end
6676

0 commit comments

Comments
 (0)