diff options
author | Andrew Smith <espadav8@gmail.com> | 2016-11-30 22:26:22 +1000 |
---|---|---|
committer | Andrew Smith <espadav8@gmail.com> | 2016-12-01 22:13:42 +1000 |
commit | 532f8cbd38d61ba73886ea3ed0dbce1864819bec (patch) | |
tree | 1b99addfbfa9722ee3ea13b1543d1fffc97c9927 | |
parent | 42dc2033dd4f04203c6f025ee96a058e050c9312 (diff) | |
download | gitlab-ce-532f8cbd38d61ba73886ea3ed0dbce1864819bec.tar.gz |
If SSH prototol is disabled don't say the user requires SSH keys
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/24921-hide-prompt-to-add-ssh-key-if-ssh-protocol-is-disabled.yml | 4 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 12 |
3 files changed, 17 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index b54ce14f0bf..b9bb4a9e3f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -512,7 +512,7 @@ class User < ActiveRecord::Base end def require_ssh_key? - keys.count == 0 + keys.count == 0 && Gitlab::ProtocolAccess.allowed?('ssh') end def require_password? diff --git a/changelogs/unreleased/24921-hide-prompt-to-add-ssh-key-if-ssh-protocol-is-disabled.yml b/changelogs/unreleased/24921-hide-prompt-to-add-ssh-key-if-ssh-protocol-is-disabled.yml new file mode 100644 index 00000000000..4d4019e770e --- /dev/null +++ b/changelogs/unreleased/24921-hide-prompt-to-add-ssh-key-if-ssh-protocol-is-disabled.yml @@ -0,0 +1,4 @@ +--- +title: Don't display prompt to add SSH keys if SSH protocol is disabled +merge_request: 7840 +author: Andrew Smith (EspadaV8) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 14c891994d0..475f4419d58 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -575,6 +575,18 @@ describe User, models: true do end end end + + context 'when current_application_settings.enabled_git_access_protocol does not contain SSH' do + before do + stub_application_setting(enabled_git_access_protocol: 'HTTP') + end + + it "doesn't require user to have SSH key" do + user = build(:user) + + expect(user.require_ssh_key?).to be_falsey + end + end end describe '.find_by_any_email' do |