Ensure oath callbacks without a nickname work (google)
This commit is contained in:
parent
5801d520a7
commit
262276c5f5
2 changed files with 13 additions and 0 deletions
|
@ -86,6 +86,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def username
|
||||
return unless auth.info.respond_to?(:nickname)
|
||||
auth.info.nickname.to_s.force_encoding("utf-8")
|
||||
end
|
||||
|
||||
|
|
|
@ -68,5 +68,17 @@ describe Gitlab::OAuth::User do
|
|||
user = gl_auth.create(auth)
|
||||
expect(user.email).to_not be_empty
|
||||
end
|
||||
|
||||
it 'generates a username if non provided (google)' do
|
||||
info = double(
|
||||
uid: 'my-uid',
|
||||
name: 'John',
|
||||
email: 'john@example.com'
|
||||
)
|
||||
auth = double(info: info, provider: 'my-provider')
|
||||
|
||||
user = gl_auth.create(auth)
|
||||
expect(user.username).to eql 'john'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue