diff options
author | Stan Hu <stanhu@gmail.com> | 2018-09-09 14:04:11 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-10 22:41:53 -0700 |
commit | ced2a932d75272e25f172b879b08de2208ce4b5c (patch) | |
tree | 6e05813f0d28d3ccf110823ec128d7257813a5c1 /spec/requests | |
parent | 2f990e3408d00cad473d8dcf8a4e49155cc3cc33 (diff) | |
download | gitlab-ce-ced2a932d75272e25f172b879b08de2208ce4b5c.tar.gz |
Add ability to skip user email confirmation with API
This gives admins the ability to send a `skip_confirmation` flag in the
`POST /users/:id/email` API endpoint to skip the verification step and
assume the given e-mail address is verified.
Closes #50876
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/users_spec.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index d48d577afa1..b7d62df0663 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -1031,11 +1031,14 @@ describe API::Users do expect(json_response['error']).to eq('email is missing') end - it "creates email" do + it "creates unverified email" do email_attrs = attributes_for :email expect do post api("/users/#{user.id}/emails", admin), email_attrs end.to change { user.emails.count }.by(1) + + email = Email.find_by(user_id: user.id, email: email_attrs[:email]) + expect(email).not_to be_confirmed end it "returns a 400 for invalid ID" do @@ -1043,6 +1046,18 @@ describe API::Users do expect(response).to have_gitlab_http_status(400) end + + it "creates verified email" do + email_attrs = attributes_for :email + email_attrs[:skip_confirmation] = true + + post api("/users/#{user.id}/emails", admin), email_attrs + + expect(response).to have_gitlab_http_status(201) + + email = Email.find_by(user_id: user.id, email: email_attrs[:email]) + expect(email).to be_confirmed + end end describe 'GET /user/:id/emails' do |