Commit c1c22d49 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch '284283-change-error-message-for-user-approval-error' into 'master'

Change error message for user approval error

See merge request gitlab-org/gitlab!52103
parents f2837c09 42e2d7d0
...@@ -8,8 +8,7 @@ module Users ...@@ -8,8 +8,7 @@ module Users
def execute(user) def execute(user)
return error(_('You are not allowed to approve a user'), :forbidden) unless allowed? 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 approval'), :conflict) if user.active? || !approval_required?(user)
return error(_('The user you are trying to approve is not pending an approval'), :conflict) unless approval_required?(user)
if user.activate if user.activate
# Resends confirmation email if the user isn't confirmed yet. # 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: ...@@ -1374,7 +1374,7 @@ Example Responses:
``` ```
```json ```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 ## Get an impersonation token of a user
......
...@@ -28460,7 +28460,7 @@ msgstr "" ...@@ -28460,7 +28460,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." 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 "" 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 "" msgstr ""
msgid "The user you are trying to deactivate has been active in the past %{minimum_inactive_days} days and cannot be deactivated" 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 ...@@ -180,7 +180,7 @@ RSpec.describe Admin::UsersController do
it 'displays the error' do it 'displays the error' do
subject 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 end
it 'does not activate the user' do it 'does not activate the user' do
......
...@@ -2565,7 +2565,7 @@ RSpec.describe API::Users do ...@@ -2565,7 +2565,7 @@ RSpec.describe API::Users do
it 'does not approve a deactivated user' do it 'does not approve a deactivated user' do
expect { approve }.not_to change { deactivated_user.reload.state } expect { approve }.not_to change { deactivated_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict) 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
end end
...@@ -2585,7 +2585,7 @@ RSpec.describe API::Users do ...@@ -2585,7 +2585,7 @@ RSpec.describe API::Users do
it 'returns 201' do it 'returns 201' do
expect { approve }.not_to change { user.reload.state } expect { approve }.not_to change { user.reload.state }
expect(response).to have_gitlab_http_status(:conflict) 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
end end
...@@ -2595,7 +2595,7 @@ RSpec.describe API::Users do ...@@ -2595,7 +2595,7 @@ RSpec.describe API::Users do
it 'returns 403' do it 'returns 403' do
expect { approve }.not_to change { blocked_user.reload.state } expect { approve }.not_to change { blocked_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict) 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
end end
...@@ -2605,7 +2605,7 @@ RSpec.describe API::Users do ...@@ -2605,7 +2605,7 @@ RSpec.describe API::Users do
it 'returns 403' do it 'returns 403' do
expect { approve }.not_to change { ldap_blocked_user.reload.state } expect { approve }.not_to change { ldap_blocked_user.reload.state }
expect(response).to have_gitlab_http_status(:conflict) 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
end end
......
...@@ -33,7 +33,7 @@ RSpec.describe Users::ApproveService do ...@@ -33,7 +33,7 @@ RSpec.describe Users::ApproveService do
it 'returns error result' do it 'returns error result' do
expect(subject[:status]).to eq(:error) expect(subject[:status]).to eq(:error)
expect(subject[:message]) 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
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