diff options
author | Valery Sizov <vsv2711@gmail.com> | 2014-11-27 14:34:39 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2014-12-04 14:03:55 +0300 |
commit | 3a5ed5260b24051939575d1934ce9b8392cac09f (patch) | |
tree | 04d361e52d16234f00e5cdd27b5ebfef9a503579 /spec/lib | |
parent | 1a80d13a3990937580c97e2b0ba8fb98f69bc055 (diff) |
Supporting for multiple omniauth provider for the same user
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ldap/user_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/oauth/user_spec.rb | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 726c9764e3d..294ee6cbae0 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -15,18 +15,18 @@ describe Gitlab::LDAP::User do describe :find_or_create do it "finds the user if already existing" do - existing_user = create(:user, extern_uid: 'my-uid', provider: 'ldapmain') + existing_user = create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain') expect{ gl_user.save }.to_not change{ User.count } end it "connects to existing non-ldap user if the email matches" do - existing_user = create(:user, email: 'john@example.com') + existing_user = create(:omniauth_user, email: 'john@example.com') expect{ gl_user.save }.to_not change{ User.count } existing_user.reload - expect(existing_user.extern_uid).to eql 'my-uid' - expect(existing_user.provider).to eql 'ldapmain' + expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid' + expect(existing_user.ldap_identity.provider).to eql 'ldapmain' end it "creates a new user if not found" do diff --git a/spec/lib/gitlab/oauth/user_spec.rb b/spec/lib/gitlab/oauth/user_spec.rb index 8a83a1b2588..88307515789 100644 --- a/spec/lib/gitlab/oauth/user_spec.rb +++ b/spec/lib/gitlab/oauth/user_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::OAuth::User do end describe :persisted? do - let!(:existing_user) { create(:user, extern_uid: 'my-uid', provider: 'my-provider') } + let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') } it "finds an existing user based on uid and provider (facebook)" do auth = double(info: double(name: 'John'), uid: 'my-uid', provider: 'my-provider') @@ -39,8 +39,9 @@ describe Gitlab::OAuth::User do oauth_user.save expect(gl_user).to be_valid - expect(gl_user.extern_uid).to eql uid - expect(gl_user.provider).to eql 'twitter' + identity = gl_user.identities.first + expect(identity.extern_uid).to eql uid + expect(identity.provider).to eql 'twitter' end end |