summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-05-24 09:46:30 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-05-24 18:19:48 +0200
commit7a139c1602016485b8a2038dfc6121e47039c669 (patch)
treedc45dbcaf05157b8538ace1233270fccebbd73d3
parentc52db71e36ee70c4c5be80b029cf4362f28e3667 (diff)
downloadgitlab-ce-bvl-add-username-to-terms-message.tar.gz
Add username to terms message in git and API callsbvl-add-username-to-terms-message
This will make it clearer to users which account is being used to make the API/git call. So they know which account needs to be used to accept the terms. Closes #46649
-rw-r--r--changelogs/unreleased/bvl-add-username-to-terms-message.yml5
-rw-r--r--lib/gitlab/auth/user_access_denied_reason.rb8
-rw-r--r--spec/lib/gitlab/auth/user_access_denied_reason_spec.rb3
-rw-r--r--spec/lib/gitlab/git_access_spec.rb2
-rw-r--r--spec/requests/api/helpers_spec.rb2
5 files changed, 13 insertions, 7 deletions
diff --git a/changelogs/unreleased/bvl-add-username-to-terms-message.yml b/changelogs/unreleased/bvl-add-username-to-terms-message.yml
new file mode 100644
index 00000000000..b95d87e9265
--- /dev/null
+++ b/changelogs/unreleased/bvl-add-username-to-terms-message.yml
@@ -0,0 +1,5 @@
+---
+title: Add username to terms message in git and API calls
+merge_request: 19126
+author:
+type: changed
diff --git a/lib/gitlab/auth/user_access_denied_reason.rb b/lib/gitlab/auth/user_access_denied_reason.rb
index af310aa12fc..1893cb001b2 100644
--- a/lib/gitlab/auth/user_access_denied_reason.rb
+++ b/lib/gitlab/auth/user_access_denied_reason.rb
@@ -8,12 +8,12 @@ module Gitlab
def rejection_message
case rejection_type
when :internal
- 'This action cannot be performed by internal users'
+ "This action cannot be performed by internal users"
when :terms_not_accepted
- 'You must accept the Terms of Service in order to perform this action. '\
- 'Please access GitLab from a web browser to accept these terms.'
+ "You (#{@user.to_reference}) must accept the Terms of Service in order to perform this action. "\
+ "Please access GitLab from a web browser to accept these terms."
else
- 'Your account has been blocked.'
+ "Your account has been blocked."
end
end
diff --git a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
index fa209bed74e..002ce776be9 100644
--- a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
+++ b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
@@ -22,7 +22,8 @@ describe Gitlab::Auth::UserAccessDeniedReason do
enforce_terms
end
- it { is_expected.to match /You must accept the Terms of Service/ }
+ it { is_expected.to match /must accept the Terms of Service/ }
+ it { is_expected.to include(user.username) }
end
context 'when the user is internal' do
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 317a932d5a6..dfffea7797f 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -1055,7 +1055,7 @@ describe Gitlab::GitAccess do
it 'blocks access when the user did not accept terms', :aggregate_failures do
actions.each do |action|
- expect { action.call }.to raise_unauthorized(/You must accept the Terms of Service in order to perform this action/)
+ expect { action.call }.to raise_unauthorized(/must accept the Terms of Service in order to perform this action/)
end
end
diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb
index d3ab44c0d7e..d8a51f36dba 100644
--- a/spec/requests/api/helpers_spec.rb
+++ b/spec/requests/api/helpers_spec.rb
@@ -171,7 +171,7 @@ describe API::Helpers do
end
it 'returns a 403 when a user has not accepted the terms' do
- expect { current_user }.to raise_error /You must accept the Terms of Service/
+ expect { current_user }.to raise_error /must accept the Terms of Service/
end
it 'sets the current user when the user accepted the terms' do