Commit 3dbac553 authored by Alishan Ladhani's avatar Alishan Ladhani

Improve and internationalize Deployment Approval error messages

Changelog: changed
EE: true
parent 6fb28081
......@@ -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
......@@ -270,7 +270,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
......
......@@ -124,13 +124,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
......@@ -138,7 +138,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
......@@ -146,19 +146,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
......@@ -166,7 +166,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
......
......@@ -37479,6 +37479,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 ""
......@@ -37506,6 +37509,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 ""
......@@ -39289,6 +39295,9 @@ msgstr ""
msgid "Unreachable"
msgstr ""
msgid "Unrecognized approval status."
msgstr ""
msgid "Unrecognized cluster type"
msgstr ""
......@@ -42114,6 +42123,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 ""
......@@ -42198,6 +42210,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