Commit 72c68b98 authored by Mark Fletcher's avatar Mark Fletcher

Fix Users API to accept confirm parameter

parent 4404ea86
---
title: Fix 500 error when POSTing to Users API with optional confirm param
merge_request:
author:
...@@ -93,7 +93,7 @@ module API ...@@ -93,7 +93,7 @@ module API
# Filter out params which are used later # Filter out params which are used later
user_params = declared_params(include_missing: false) user_params = declared_params(include_missing: false)
identity_attrs = user_params.slice(:provider, :extern_uid) 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 = User.new(user_params.except(:extern_uid, :provider))
user.skip_confirmation! unless confirm user.skip_confirmation! unless confirm
......
...@@ -137,6 +137,15 @@ describe API::Users, api: true do ...@@ -137,6 +137,15 @@ describe API::Users, api: true do
expect(new_user.can_create_group).to eq(true) expect(new_user.can_create_group).to eq(true)
end 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 it "creates non-admin user" do
post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false) post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
expect(response).to have_http_status(201) 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