Commit 42e2d7d0 authored by Jackie Fraser's avatar Jackie Fraser Committed by Mikołaj Wawrzyniak

Change error message for user approval error

parent 50fb21a5
......@@ -8,8 +8,7 @@ module Users
def execute(user)
return error(_('You are not allowed to approve a user'), :forbidden) unless allowed?
return error(_('The user you are trying to approve is not pending an approval'), :conflict) if user.active?
return error(_('The user you are trying to approve is not pending an approval'), :conflict) unless approval_required?(user)
return error(_('The user you are trying to approve is not pending approval'), :conflict) if user.active? || !approval_required?(user)
if user.activate
# Resends confirmation email if the user isn't confirmed yet.
......
---
title: Change error message for user approval error
merge_request: 52103
author:
type: changed
......@@ -1374,7 +1374,7 @@ Example Responses:
```
```json
{ "message": "The user you are trying to approve is not pending an approval" }
{ "message": "The user you are trying to approve is not pending approval" }
```
## Get an impersonation token of a user
......
......@@ -28382,7 +28382,7 @@ msgstr ""
msgid "The user map is a mapping of the FogBugz users that participated on your projects to the way their email address and usernames will be imported into GitLab. You can change this by populating the table below."
msgstr ""
msgid "The user you are trying to approve is not pending an approval"
msgid "The user you are trying to approve is not pending approval"
msgstr ""
msgid "The user you are trying to deactivate has been active in the past %{minimum_inactive_days} days and cannot be deactivated"
......
......@@ -180,7 +180,7 @@ RSpec.describe Admin::UsersController do
it 'displays the error' do
subject
expect(flash[:alert]).to eq('The user you are trying to approve is not pending an approval')
expect(flash[:alert]).to eq('The user you are trying to approve is not pending approval')
end
it 'does not activate the user' do
......
......@@ -2565,7 +2565,7 @@ RSpec.describe API::Users do
it 'does not approve a deactivated user' do
expect { approve }.not_to change { deactivated_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('The user you are trying to approve is not pending an approval')
expect(json_response['message']).to eq('The user you are trying to approve is not pending approval')
end
end
......@@ -2585,7 +2585,7 @@ RSpec.describe API::Users do
it 'returns 201' do
expect { approve }.not_to change { user.reload.state }
expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('The user you are trying to approve is not pending an approval')
expect(json_response['message']).to eq('The user you are trying to approve is not pending approval')
end
end
......@@ -2595,7 +2595,7 @@ RSpec.describe API::Users do
it 'returns 403' do
expect { approve }.not_to change { blocked_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('The user you are trying to approve is not pending an approval')
expect(json_response['message']).to eq('The user you are trying to approve is not pending approval')
end
end
......@@ -2605,7 +2605,7 @@ RSpec.describe API::Users do
it 'returns 403' do
expect { approve }.not_to change { ldap_blocked_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('The user you are trying to approve is not pending an approval')
expect(json_response['message']).to eq('The user you are trying to approve is not pending approval')
end
end
......
......@@ -33,7 +33,7 @@ RSpec.describe Users::ApproveService do
it 'returns error result' do
expect(subject[:status]).to eq(:error)
expect(subject[:message])
.to match(/The user you are trying to approve is not pending an approval/)
.to match(/The user you are trying to approve is not pending approval/)
end
end
......
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