FIX: wasn't able to use the same username when taking over a staged account

This commit is contained in:
Régis Hanol
2017-12-12 11:26:00 +01:00
parent 7d8cd84fa6
commit 62a5b174e1
3 changed files with 14 additions and 4 deletions

View File

@ -484,9 +484,16 @@ describe User do
it 'returns false when a username is reserved' do
SiteSetting.reserved_usernames = 'test|donkey'
expect(User.username_available?('tESt')).to eq(false)
end
it "returns true when username is associated to a staged user of the same email" do
staged = Fabricate(:user, staged: true, email: "foo@bar.com")
expect(User.username_available?(staged.username, staged.primary_email.email)).to eq(true)
user = Fabricate(:user, email: "bar@foo.com")
expect(User.username_available?(user.username, user.primary_email.email)).to eq(false)
end
end
describe '.reserved_username?' do