Skip to content
Snippets Groups Projects
Commit 26b14dd2 authored by Jan-Willem van der Meer's avatar Jan-Willem van der Meer
Browse files

Get uid from auth instead of info hash

parent 92a99649
No related branches found
No related tags found
No related merge requests found
Loading
@@ -67,9 +67,7 @@ module Gitlab
Loading
@@ -67,9 +67,7 @@ module Gitlab
end end
   
def uid def uid
uid = auth.info.try(:uid) || auth.uid auth.uid.to_s
uid = uid.to_s unless uid.nil?
uid
end end
   
def email def email
Loading
Loading
Loading
@@ -4,7 +4,6 @@ describe Gitlab::OAuth::User do
Loading
@@ -4,7 +4,6 @@ describe Gitlab::OAuth::User do
let(:gl_auth) { Gitlab::OAuth::User } let(:gl_auth) { Gitlab::OAuth::User }
let(:info) do let(:info) do
double( double(
uid: 'my-uid',
nickname: 'john', nickname: 'john',
name: 'John', name: 'John',
email: 'john@mail.com' email: 'john@mail.com'
Loading
@@ -24,32 +23,32 @@ describe Gitlab::OAuth::User do
Loading
@@ -24,32 +23,32 @@ describe Gitlab::OAuth::User do
end end
   
it "finds an existing user based on nested uid and provider" do it "finds an existing user based on nested uid and provider" do
auth = double(info: info, provider: 'my-provider') auth = double(info: info, uid: 'my-uid', provider: 'my-provider')
assert gl_auth.find(auth) assert gl_auth.find(auth)
end end
end end
   
describe :create do describe :create do
it "should create user from LDAP" do it "should create user from LDAP" do
auth = double(info: info, provider: 'ldap') auth = double(info: info, uid: 'my-uid', provider: 'ldap')
user = gl_auth.create(auth) user = gl_auth.create(auth)
   
user.should be_valid user.should be_valid
user.extern_uid.should == info.uid user.extern_uid.should == auth.uid
user.provider.should == 'ldap' user.provider.should == 'ldap'
end end
   
it "should create user from Omniauth" do it "should create user from Omniauth" do
auth = double(info: info, provider: 'twitter') auth = double(info: info, uid: 'my-uid', provider: 'twitter')
user = gl_auth.create(auth) user = gl_auth.create(auth)
   
user.should be_valid user.should be_valid
user.extern_uid.should == info.uid user.extern_uid.should == auth.uid
user.provider.should == 'twitter' user.provider.should == 'twitter'
end end
   
it "should apply defaults to user" do it "should apply defaults to user" do
auth = double(info: info, provider: 'ldap') auth = double(info: info, uid: 'my-uid', provider: 'ldap')
user = gl_auth.create(auth) user = gl_auth.create(auth)
   
user.should be_valid user.should be_valid
Loading
@@ -63,7 +62,7 @@ describe Gitlab::OAuth::User do
Loading
@@ -63,7 +62,7 @@ describe Gitlab::OAuth::User do
nickname: 'john', nickname: 'john',
name: 'John' name: 'John'
) )
auth = double(info: info, provider: 'my-provider') auth = double(info: info, uid: 'my-uid', provider: 'my-provider')
   
user = gl_auth.create(auth) user = gl_auth.create(auth)
expect(user.email).to_not be_empty expect(user.email).to_not be_empty
Loading
@@ -75,7 +74,7 @@ describe Gitlab::OAuth::User do
Loading
@@ -75,7 +74,7 @@ describe Gitlab::OAuth::User do
name: 'John', name: 'John',
email: 'john@example.com' email: 'john@example.com'
) )
auth = double(info: info, provider: 'my-provider') auth = double(info: info, uid: 'my-uid', provider: 'my-provider')
   
user = gl_auth.create(auth) user = gl_auth.create(auth)
expect(user.username).to eql 'john' expect(user.username).to eql 'john'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment