diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-05-28 12:53:58 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-05-28 12:53:58 +0300 |
commit | a45b9fc96ca568b19fd9d09a8b40846c2c8b5b36 (patch) | |
tree | ecc3e3274e9d13be5c294068d44ff12b9d92ccb8 | |
parent | 5f5fc69dde0d7098b72b047090c8a4f56d495002 (diff) | |
parent | 7a139c1602016485b8a2038dfc6121e47039c669 (diff) |
Merge branch 'bvl-add-username-to-terms-message' into 'master'
Add username to terms message in git and API calls
Closes #46649
See merge request gitlab-org/gitlab-ce!19126
-rw-r--r-- | changelogs/unreleased/bvl-add-username-to-terms-message.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/auth/user_access_denied_reason.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/user_access_denied_reason_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/git_access_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/helpers_spec.rb | 2 |
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 |