gitlab-org--gitlab-foss/spec/lib/oauth_spec.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2013-09-03 17:53:13 -04:00
require 'spec_helper'
describe Gitlab::OAuth::User do
let(:gl_auth) { Gitlab::OAuth::User }
before do
Gitlab.config.stub(omniauth: {})
2013-12-14 08:43:48 -05:00
@info = double(
2013-09-03 17:53:13 -04:00
uid: '12djsak321',
name: 'John',
email: 'john@mail.com'
)
end
describe :create do
it "should create user from LDAP" do
2013-12-14 08:43:48 -05:00
@auth = double(info: @info, provider: 'ldap')
2013-09-03 17:53:13 -04:00
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
2013-12-14 08:43:48 -05:00
@auth = double(info: @info, provider: 'twitter')
2013-09-03 17:53:13 -04:00
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
2013-12-14 08:43:48 -05:00
@auth = double(info: @info, provider: 'ldap')
2013-09-03 17:53:13 -04:00
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