Commit 34087fe3 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-user-api-confirm-param' into 'master'

Fix Users API to accept confirm parameter

Closes #26295

See merge request !8531
parents 3fc91a35 72c68b98
---
title: Fix 500 error when POSTing to Users API with optional confirm param
merge_request:
author:
......@@ -93,7 +93,7 @@ module API
# Filter out params which are used later
user_params = declared_params(include_missing: false)
identity_attrs = user_params.slice(:provider, :extern_uid)
confirm = params.delete(:confirm)
confirm = user_params.delete(:confirm)
user = User.new(user_params.except(:extern_uid, :provider))
user.skip_confirmation! unless confirm
......
......@@ -137,6 +137,15 @@ describe API::Users, api: true do
expect(new_user.can_create_group).to eq(true)
end
it "creates user with optional attributes" do
optional_attributes = { confirm: true }
attributes = attributes_for(:user).merge(optional_attributes)
post api('/users', admin), attributes
expect(response).to have_http_status(201)
end
it "creates non-admin user" do
post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
expect(response).to have_http_status(201)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment