Commit a45b9fc9 authored by Douwe Maan's avatar Douwe Maan

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
parents 5f5fc69d 7a139c16
---
title: Add username to terms message in git and API calls
merge_request: 19126
author:
type: changed
...@@ -8,12 +8,12 @@ module Gitlab ...@@ -8,12 +8,12 @@ module Gitlab
def rejection_message def rejection_message
case rejection_type case rejection_type
when :internal when :internal
'This action cannot be performed by internal users' "This action cannot be performed by internal users"
when :terms_not_accepted when :terms_not_accepted
'You must accept the Terms of Service in order to perform this action. '\ "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.' "Please access GitLab from a web browser to accept these terms."
else else
'Your account has been blocked.' "Your account has been blocked."
end end
end end
......
...@@ -22,7 +22,8 @@ describe Gitlab::Auth::UserAccessDeniedReason do ...@@ -22,7 +22,8 @@ describe Gitlab::Auth::UserAccessDeniedReason do
enforce_terms enforce_terms
end 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 end
context 'when the user is internal' do context 'when the user is internal' do
......
...@@ -1055,7 +1055,7 @@ describe Gitlab::GitAccess do ...@@ -1055,7 +1055,7 @@ describe Gitlab::GitAccess do
it 'blocks access when the user did not accept terms', :aggregate_failures do it 'blocks access when the user did not accept terms', :aggregate_failures do
actions.each do |action| 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
end end
......
...@@ -171,7 +171,7 @@ describe API::Helpers do ...@@ -171,7 +171,7 @@ describe API::Helpers do
end end
it 'returns a 403 when a user has not accepted the terms' do 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 end
it 'sets the current user when the user accepted the terms' do it 'sets the current user when the user accepted the terms' do
......
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