diff options
author | Dmitry Medvinsky <me@dmedvinsky.name> | 2013-03-11 10:44:45 +0400 |
---|---|---|
committer | Dmitry Medvinsky <me@dmedvinsky.name> | 2013-05-16 18:02:22 +0400 |
commit | 22279bc55870435c61d5e8208cc3117ef2268052 (patch) | |
tree | 1433f090b459f8573619121533546de8c2b32a02 /spec | |
parent | 3e115faafa13a0bcad5458a9632dec909eb376da (diff) |
Add settings for user permission defaults
“Can create groups” and “Can create teams” had hardcoded defaults to
`true`. Sometimes it is desirable to prohibit these for newly created
users by default.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/admin/admin_users_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/auth_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 18 |
3 files changed, 36 insertions, 0 deletions
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index a6cf5299791..bec43e5029c 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -33,6 +33,14 @@ describe "Admin::Users" do expect { click_button "Create user" }.to change {User.count}.by(1) end + it "should apply defaults to user" do + click_button "Create user" + user = User.last + user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit + user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group + user.can_create_team.should == Gitlab.config.gitlab.default_can_create_team + end + it "should create user with valid data" do click_button "Create user" user = User.last diff --git a/spec/lib/auth_spec.rb b/spec/lib/auth_spec.rb index 1e03bc591b4..a7ce97554ea 100644 --- a/spec/lib/auth_spec.rb +++ b/spec/lib/auth_spec.rb @@ -91,5 +91,15 @@ describe Gitlab::Auth do user.extern_uid.should == @info.uid user.provider.should == 'twitter' end + + it "should apply defaults to user" do + @auth = mock(info: @info, provider: 'ldap') + user = gl_auth.create_from_omniauth(@auth, true) + + 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 + user.can_create_team.should == Gitlab.config.gitlab.default_can_create_team + end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 380bbe7351f..7559c4cc3a1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -178,4 +178,22 @@ describe User do it { user.can_create_project?.should be_true } it { user.first_name.should == 'John' } end + + describe 'without defaults' do + let(:user) { User.new } + it "should not apply defaults to user" do + user.projects_limit.should == 10 + user.can_create_group.should == true + user.can_create_team.should == true + end + end + + describe 'with defaults' do + let(:user) { User.new.with_defaults } + it "should apply defaults to user" do + user.projects_limit.should == 42 + user.can_create_group.should == false + user.can_create_team.should == false + end + end end |