Commit cb83bdef authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'ali/improve-deployment-approval-error-messages' into 'master'

Improve and internationalize Deployment Approval error messages

See merge request gitlab-org/gitlab!82454
parents 3ca75a1f 3dbac553
......@@ -38,15 +38,15 @@ module Deployments
end
def validate(deployment, status)
return 'Unrecognized status' unless Deployments::Approval.statuses.include?(status)
return _('Unrecognized approval status.') unless Deployments::Approval.statuses.include?(status)
return 'This environment is not protected' unless deployment.environment.protected?
return _('This environment is not protected.') unless deployment.environment.protected?
return 'You do not have permission to approve or reject this deployment' unless current_user&.can?(:update_deployment, deployment)
return _("You don't have permission to review this deployment. Contact the project or group owner for help.") unless current_user&.can?(:update_deployment, deployment)
return 'This deployment job is not waiting for approvals' unless deployment.blocked?
return _('This deployment is not waiting for approvals.') unless deployment.blocked?
'The same user can not approve' if deployment.user == current_user && status == 'approved'
_('You cannot approve your own deployment.') if deployment.user == current_user && status == 'approved'
end
end
end
......@@ -284,7 +284,7 @@ RSpec.describe API::Deployments do
end
context 'and user is not authorized to update deployment' do
include_examples 'not created', response_status: :bad_request, message: 'You do not have permission to approve or reject this deployment'
include_examples 'not created', response_status: :bad_request, message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end
context 'with an invalid status' do
......
......@@ -157,13 +157,13 @@ RSpec.describe Deployments::ApprovalService do
context 'when status is not recognized' do
let(:status) { 'foo' }
include_examples 'error', message: 'Unrecognized status'
include_examples 'error', message: 'Unrecognized approval status.'
end
context 'when environment is not protected' do
let(:deployment) { create(:deployment, project: project, deployable: build) }
include_examples 'error', message: 'This environment is not protected'
include_examples 'error', message: 'This environment is not protected.'
end
context 'when Protected Environments feature is not available' do
......@@ -171,7 +171,7 @@ RSpec.describe Deployments::ApprovalService do
stub_licensed_features(protected_environments: false)
end
include_examples 'error', message: 'This environment is not protected'
include_examples 'error', message: 'This environment is not protected.'
end
context 'when the user does not have permission to update deployment' do
......@@ -179,19 +179,19 @@ RSpec.describe Deployments::ApprovalService do
project.add_developer(user)
end
include_examples 'error', message: 'You do not have permission to approve or reject this deployment'
include_examples 'error', message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end
context 'when user is nil' do
let(:user) { nil }
include_examples 'error', message: 'You do not have permission to approve or reject this deployment'
include_examples 'error', message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end
context 'when deployment is not blocked' do
let(:deployment) { create(:deployment, project: project, environment: environment, deployable: build) }
include_examples 'error', message: 'This deployment job is not waiting for approvals'
include_examples 'error', message: 'This deployment is not waiting for approvals.'
end
context 'when the creator of the deployment is approving' do
......@@ -199,7 +199,7 @@ RSpec.describe Deployments::ApprovalService do
deployment.user = user
end
include_examples 'error', message: 'The same user can not approve'
include_examples 'error', message: 'You cannot approve your own deployment.'
end
context 'when the creator of the deployment is rejecting' do
......
......@@ -37582,6 +37582,9 @@ msgstr ""
msgid "This credential has expired"
msgstr ""
msgid "This deployment is not waiting for approvals."
msgstr ""
msgid "This device has already been registered with us."
msgstr ""
......@@ -37609,6 +37612,9 @@ msgstr ""
msgid "This environment is being re-deployed"
msgstr ""
msgid "This environment is not protected."
msgstr ""
msgid "This environment's canary ingress has been updated recently. Please retry later."
msgstr ""
......@@ -39392,6 +39398,9 @@ msgstr ""
msgid "Unreachable"
msgstr ""
msgid "Unrecognized approval status."
msgstr ""
msgid "Unrecognized cluster type"
msgstr ""
......@@ -42220,6 +42229,9 @@ msgstr ""
msgid "You cannot access the raw file. Please wait a minute."
msgstr ""
msgid "You cannot approve your own deployment."
msgstr ""
msgid "You cannot combine replace_ids with add_ids or remove_ids"
msgstr ""
......@@ -42304,6 +42316,9 @@ msgstr ""
msgid "You don't have any recent searches"
msgstr ""
msgid "You don't have permission to review this deployment. Contact the project or group owner for help."
msgstr ""
msgid "You don't have sufficient permission to perform this action."
msgstr ""
......
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