mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: Perform better email validation (#12497)
Using UserEmail for validation is not sufficient because it checks the emails of staged users too.
This commit is contained in:
@ -1592,6 +1592,11 @@ describe UsersController do
|
||||
expect(response.parsed_body["success"]).to be_present
|
||||
end
|
||||
|
||||
it 'returns success if email is empty' do
|
||||
get "/u/check_email.json"
|
||||
expect(response.parsed_body["success"]).to be_present
|
||||
end
|
||||
|
||||
it 'returns failure if email is not valid' do
|
||||
get "/u/check_email.json", params: { email: "invalid" }
|
||||
expect(response.parsed_body["failed"]).to be_present
|
||||
@ -1600,12 +1605,20 @@ describe UsersController do
|
||||
it 'returns failure if email exists' do
|
||||
get "/u/check_email.json", params: { email: user.email }
|
||||
expect(response.parsed_body["failed"]).to be_present
|
||||
|
||||
get "/u/check_email.json", params: { email: user.email.upcase }
|
||||
expect(response.parsed_body["failed"]).to be_present
|
||||
end
|
||||
|
||||
it 'returns success if email does not exists' do
|
||||
get "/u/check_email.json", params: { email: "available@example.com" }
|
||||
expect(response.parsed_body["success"]).to be_present
|
||||
end
|
||||
|
||||
it 'return success if user email is taken by staged user' do
|
||||
get "/u/check_email.json", params: { email: Fabricate(:staged).email }
|
||||
expect(response.parsed_body["success"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
describe '#invited' do
|
||||
|
Reference in New Issue
Block a user