From 4f0360c7a2ac455a671a688ea897319a73e246b2 Mon Sep 17 00:00:00 2001 From: Jordan Brough Date: Fri, 30 Sep 2022 11:28:18 -0700 Subject: [PATCH] chore: Allow setting "users.display_name" in Platform API (#5532) --- .../platform/api/v1/users_controller.rb | 2 +- .../platform/api/v1/users_controller_spec.rb | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/platform/api/v1/users_controller.rb b/app/controllers/platform/api/v1/users_controller.rb index 12c87deb5..2c8995f81 100644 --- a/app/controllers/platform/api/v1/users_controller.rb +++ b/app/controllers/platform/api/v1/users_controller.rb @@ -51,6 +51,6 @@ class Platform::Api::V1::UsersController < PlatformController end def user_params - params.permit(:name, :email, :password, custom_attributes: {}) + params.permit(:name, :display_name, :email, :password, custom_attributes: {}) end end diff --git a/spec/controllers/platform/api/v1/users_controller_spec.rb b/spec/controllers/platform/api/v1/users_controller_spec.rb index 57fa81bd4..ca3cd3bf9 100644 --- a/spec/controllers/platform/api/v1/users_controller_spec.rb +++ b/spec/controllers/platform/api/v1/users_controller_spec.rb @@ -96,15 +96,24 @@ RSpec.describe 'Platform Users API', type: :request do it 'creates a new user and permissible for the user' do expect do - post '/platform/api/v1/users/', params: { name: 'test', email: 'test@test.com', password: 'Password1!', + post '/platform/api/v1/users/', params: { name: 'test', display_name: 'displaytest', + email: 'test@test.com', password: 'Password1!', custom_attributes: { test: 'test_create' } }, headers: { api_access_token: platform_app.access_token.token }, as: :json end.not_to enqueue_mail expect(response).to have_http_status(:success) data = JSON.parse(response.body) - expect(data['email']).to eq('test@test.com') - expect(data['custom_attributes']['test']).to eq('test_create') + expect(data).to match( + hash_including( + 'name' => 'test', + 'display_name' => 'displaytest', + 'email' => 'test@test.com', + 'custom_attributes' => { + 'test' => 'test_create' + } + ) + ) expect(platform_app.platform_app_permissibles.first.permissible_id).to eq data['id'] end