mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 12:02:05 +08:00
FIX: do not allow new email to be duplicate
FIX: return proper error message when email already exists
This commit is contained in:
@ -242,11 +242,13 @@ describe UsersController do
|
||||
context 'when the new email address is taken' do
|
||||
let!(:other_user) { Fabricate(:coding_horror) }
|
||||
it 'raises an error' do
|
||||
expect { xhr :put, :change_email, username: user.username, email: other_user.email }.to raise_error(Discourse::InvalidParameters)
|
||||
xhr :put, :change_email, username: user.username, email: other_user.email
|
||||
expect(response).to_not be_success
|
||||
end
|
||||
|
||||
it 'raises an error if there is whitespace too' do
|
||||
expect { xhr :put, :change_email, username: user.username, email: other_user.email + ' ' }.to raise_error(Discourse::InvalidParameters)
|
||||
xhr :put, :change_email, username: user.username, email: other_user.email + ' '
|
||||
expect(response).to_not be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -254,7 +256,8 @@ describe UsersController do
|
||||
let!(:other_user) { Fabricate(:user, email: 'case.insensitive@gmail.com')}
|
||||
|
||||
it 'raises an error' do
|
||||
expect { xhr :put, :change_email, username: user.username, email: other_user.email.upcase }.to raise_error(Discourse::InvalidParameters)
|
||||
xhr :put, :change_email, username: user.username, email: other_user.email.upcase
|
||||
expect(response).to_not be_success
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user