diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-14 11:49:36 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-14 11:49:36 +0300 |
commit | 1afdbe320e60aa227dfd75ae1f1f128106660c8a (patch) | |
tree | 38e91b764c45b2f0074829560325d0f4b2b4ae39 /spec/models/user_spec.rb | |
parent | febd3884a293859a63d2a7ae83b969fc33448f26 (diff) | |
parent | 672a68d3724bcae676d18244c85566e7d664a169 (diff) |
Merge branch 'fixes-for-internal-auth-disabled' into 'master'
Fixes needed when GitLab sign-in is not enabled
See merge request !12491
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c70f916a8bd..c614df8e98a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1932,4 +1932,26 @@ describe User, models: true do user.invalidate_merge_request_cache_counts end end + + describe '#allow_password_authentication?' do + context 'regular user' do + let(:user) { build(:user) } + + it 'returns true when sign-in is enabled' do + expect(user.allow_password_authentication?).to be_truthy + end + + it 'returns false when sign-in is disabled' do + stub_application_setting(password_authentication_enabled: false) + + expect(user.allow_password_authentication?).to be_falsey + end + end + + it 'returns false for ldap user' do + user = create(:omniauth_user, provider: 'ldapmain') + + expect(user.allow_password_authentication?).to be_falsey + end + end end |