Commit 9dcbeca8 authored by George Thomas's avatar George Thomas

Hide PAT creation advice for HTTP clone if PAT exist

If the user has a active Personal Access Token, hide the help text that
appears when selecting the link for HTTP clone
parent 472f2d56
...@@ -67,7 +67,7 @@ module ButtonHelper ...@@ -67,7 +67,7 @@ module ButtonHelper
def http_dropdown_description(protocol) def http_dropdown_description(protocol)
if current_user.try(:require_password_creation_for_git?) if current_user.try(:require_password_creation_for_git?)
_("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol } _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol }
else elsif current_user.try(:require_personal_access_token_creation_for_git_auth?)
_("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol } _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol }
end end
end end
......
---
title: Hide PAT creation advice for HTTP clone if PAT exists
merge_request: 18208
author: George Thomas @thegeorgeous
type: fixed
...@@ -40,12 +40,24 @@ describe ButtonHelper do ...@@ -40,12 +40,24 @@ describe ButtonHelper do
end end
context 'when user has no personal access tokens' do context 'when user has no personal access tokens' do
it 'has a personal access token text on the dropdown description ' do it 'has a personal access token text on the dropdown description' do
description = element.search('.dropdown-menu-inner-content').first description = element.search('.dropdown-menu-inner-content').first
expect(description.inner_text).to eq 'Create a personal access token on your account to pull or push via HTTP.' expect(description.inner_text).to eq 'Create a personal access token on your account to pull or push via HTTP.'
end end
end end
context 'when user has personal access tokens' do
before do
create(:personal_access_token, user: user)
end
it 'does not have a personal access token text on the dropdown description' do
description = element.search('.dropdown-menu-inner-content').first
expect(description).to be_nil
end
end
end end
context 'when user is ldap user' do context 'when user is ldap user' 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