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 ...@@ -38,15 +38,15 @@ module Deployments
end end
def validate(deployment, status) 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 end
end end
...@@ -270,7 +270,7 @@ RSpec.describe API::Deployments do ...@@ -270,7 +270,7 @@ RSpec.describe API::Deployments do
end end
context 'and user is not authorized to update deployment' do 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 end
context 'with an invalid status' do context 'with an invalid status' do
......
...@@ -124,13 +124,13 @@ RSpec.describe Deployments::ApprovalService do ...@@ -124,13 +124,13 @@ RSpec.describe Deployments::ApprovalService do
context 'when status is not recognized' do context 'when status is not recognized' do
let(:status) { 'foo' } let(:status) { 'foo' }
include_examples 'error', message: 'Unrecognized status' include_examples 'error', message: 'Unrecognized approval status.'
end end
context 'when environment is not protected' do context 'when environment is not protected' do
let(:deployment) { create(:deployment, project: project, deployable: build) } 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 end
context 'when Protected Environments feature is not available' do context 'when Protected Environments feature is not available' do
...@@ -138,7 +138,7 @@ RSpec.describe Deployments::ApprovalService do ...@@ -138,7 +138,7 @@ RSpec.describe Deployments::ApprovalService do
stub_licensed_features(protected_environments: false) stub_licensed_features(protected_environments: false)
end end
include_examples 'error', message: 'This environment is not protected' include_examples 'error', message: 'This environment is not protected.'
end end
context 'when the user does not have permission to update deployment' do context 'when the user does not have permission to update deployment' do
...@@ -146,19 +146,19 @@ RSpec.describe Deployments::ApprovalService do ...@@ -146,19 +146,19 @@ RSpec.describe Deployments::ApprovalService do
project.add_developer(user) project.add_developer(user)
end 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 end
context 'when user is nil' do context 'when user is nil' do
let(:user) { nil } 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 end
context 'when deployment is not blocked' do context 'when deployment is not blocked' do
let(:deployment) { create(:deployment, project: project, environment: environment, deployable: build) } 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 end
context 'when the creator of the deployment is approving' do context 'when the creator of the deployment is approving' do
...@@ -166,7 +166,7 @@ RSpec.describe Deployments::ApprovalService do ...@@ -166,7 +166,7 @@ RSpec.describe Deployments::ApprovalService do
deployment.user = user deployment.user = user
end end
include_examples 'error', message: 'The same user can not approve' include_examples 'error', message: 'You cannot approve your own deployment.'
end end
context 'when the creator of the deployment is rejecting' do context 'when the creator of the deployment is rejecting' do
......
...@@ -37479,6 +37479,9 @@ msgstr "" ...@@ -37479,6 +37479,9 @@ msgstr ""
msgid "This credential has expired" msgid "This credential has expired"
msgstr "" msgstr ""
msgid "This deployment is not waiting for approvals."
msgstr ""
msgid "This device has already been registered with us." msgid "This device has already been registered with us."
msgstr "" msgstr ""
...@@ -37506,6 +37509,9 @@ msgstr "" ...@@ -37506,6 +37509,9 @@ msgstr ""
msgid "This environment is being re-deployed" msgid "This environment is being re-deployed"
msgstr "" msgstr ""
msgid "This environment is not protected."
msgstr ""
msgid "This environment's canary ingress has been updated recently. Please retry later." msgid "This environment's canary ingress has been updated recently. Please retry later."
msgstr "" msgstr ""
...@@ -39289,6 +39295,9 @@ msgstr "" ...@@ -39289,6 +39295,9 @@ msgstr ""
msgid "Unreachable" msgid "Unreachable"
msgstr "" msgstr ""
msgid "Unrecognized approval status."
msgstr ""
msgid "Unrecognized cluster type" msgid "Unrecognized cluster type"
msgstr "" msgstr ""
...@@ -42114,6 +42123,9 @@ msgstr "" ...@@ -42114,6 +42123,9 @@ msgstr ""
msgid "You cannot access the raw file. Please wait a minute." msgid "You cannot access the raw file. Please wait a minute."
msgstr "" msgstr ""
msgid "You cannot approve your own deployment."
msgstr ""
msgid "You cannot combine replace_ids with add_ids or remove_ids" msgid "You cannot combine replace_ids with add_ids or remove_ids"
msgstr "" msgstr ""
...@@ -42198,6 +42210,9 @@ msgstr "" ...@@ -42198,6 +42210,9 @@ msgstr ""
msgid "You don't have any recent searches" msgid "You don't have any recent searches"
msgstr "" 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." msgid "You don't have sufficient permission to perform this action."
msgstr "" 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