Commit 5e907315 authored by Etienne Baqué's avatar Etienne Baqué

Updated code based on reviewer's comments

parent 4cd1e372
......@@ -11,9 +11,6 @@ module Gitlab
module Ldap
class User < Gitlab::Auth::OAuth::User
extend ::Gitlab::Utils::Override
def save
super(protocol_name)
end
# instance methods
def find_user
......
......@@ -46,7 +46,7 @@ module Gitlab
valid? && persisted?
end
def save(provider = 'OAuth')
def save(provider = protocol_name)
raise SigninDisabledForProviderError if oauth_provider_disabled?
raise SignupDisabledError unless gl_user
......@@ -97,7 +97,7 @@ module Gitlab
end
def protocol_name
''
'OAuth'
end
protected
......
......@@ -11,10 +11,6 @@ module Gitlab
class User < Gitlab::Auth::OAuth::User
extend ::Gitlab::Utils::Override
def save
super(protocol_name)
end
def find_user
user = find_by_uid_and_provider
......
......@@ -587,7 +587,7 @@ RSpec.describe Gitlab::Auth::OAuth::User do
context 'when a sign up user cap has been set up but has not been reached yet' do
it 'still creates a blocked user' do
allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(999)
stub_application_setting(new_user_signups_cap: 999)
oauth_user.save # rubocop:disable Rails/SaveBang
expect(gl_user).to be_valid
......@@ -612,9 +612,9 @@ RSpec.describe Gitlab::Auth::OAuth::User do
before do
stub_omniauth_config({
allow_single_sign_on: ['saml'],
auto_link_saml_user: true,
block_auto_created_users: block_auto_created_users
allow_single_sign_on: ['saml'],
auto_link_saml_user: true,
block_auto_created_users: block_auto_created_users
})
end
......@@ -1049,8 +1049,8 @@ RSpec.describe Gitlab::Auth::OAuth::User do
end
describe '#protocol_name' do
it 'is empty' do
expect(oauth_user.protocol_name).to eq('')
it 'is OAuth' do
expect(oauth_user.protocol_name).to eq('OAuth')
end
end
end
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