summaryrefslogtreecommitdiff
path: root/spec/lib/oauth_spec.rb
blob: 2f15b5e03496a0097f94fe37bd0150c94b34ac1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'

describe Gitlab::OAuth::User do
  let(:gl_auth) { Gitlab::OAuth::User }

  before do
    Gitlab.config.stub(omniauth: {})

    @info = double(
      uid: '12djsak321',
      nickname: 'john',
      name: 'John',
      email: 'john@mail.com'
    )
  end

  describe :create do
    it "should create user from LDAP" do
      @auth = double(info: @info, provider: 'ldap')
      user = gl_auth.create(@auth)

      user.should be_valid
      user.extern_uid.should == @info.uid
      user.provider.should == 'ldap'
    end

    it "should create user from Omniauth" do
      @auth = double(info: @info, provider: 'twitter')
      user = gl_auth.create(@auth)

      user.should be_valid
      user.extern_uid.should == @info.uid
      user.provider.should == 'twitter'
    end

    it "should apply defaults to user" do
      @auth = double(info: @info, provider: 'ldap')
      user = gl_auth.create(@auth)

      user.should be_valid
      user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
      user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
    end
  end
end