From 2f560346e14a3cc80b6476e75b67f8ed2044b4f1 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Mon, 11 Mar 2024 00:28:40 +0000 Subject: [PATCH] Refactor user_invite initialization in users_controller.rb --- app/controllers/schools/users_controller.rb | 6 +++++- app/services/schools/dfe_sign_in_api/user_invite.rb | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/schools/users_controller.rb b/app/controllers/schools/users_controller.rb index 6ad3ab1d0f..52384492d7 100644 --- a/app/controllers/schools/users_controller.rb +++ b/app/controllers/schools/users_controller.rb @@ -7,7 +7,11 @@ def index end def new - @user_invite = DFESignInAPI::UserInvite.new(user_params) + @user_invite = if user_params.present? + DFESignInAPI::UserInvite.new(user_params) + else + DFESignInAPI::UserInvite.new + end end def create diff --git a/app/services/schools/dfe_sign_in_api/user_invite.rb b/app/services/schools/dfe_sign_in_api/user_invite.rb index 2bc5a4eebb..8edf0fc85e 100644 --- a/app/services/schools/dfe_sign_in_api/user_invite.rb +++ b/app/services/schools/dfe_sign_in_api/user_invite.rb @@ -18,6 +18,8 @@ class UserInvite < Client def invite_user @response ||= response + @response['success'] = @response['status'] == 'success' if @response.present? + @response end private