summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-16 18:27:16 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-16 18:27:16 +0200
commit592412992daf1830fb1df5cc06aac02814c6f911 (patch)
treeae4098f429ad8c4ac3851872551442c448da106a /spec
parent26afde94fda0026fd52078427e3f52e804ba8404 (diff)
downloadgitlab-ce-592412992daf1830fb1df5cc06aac02814c6f911.tar.gz
Account role spec
Diffstat (limited to 'spec')
-rw-r--r--spec/models/user_spec.rb16
-rw-r--r--spec/roles/account_role_spec.rb44
2 files changed, 48 insertions, 12 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 79ffc05bca9..d09484f8fe0 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -66,6 +66,10 @@ describe User do
it { should ensure_length_of(:bio).is_within(0..255) }
end
+ describe 'modules' do
+ it { should include_module(Account) }
+ end
+
describe "Respond to" do
it { should respond_to(:is_admin?) }
it { should respond_to(:identifier) }
@@ -115,16 +119,4 @@ describe User do
user.authentication_token.should_not be_blank
end
end
-
- describe 'projects and namespaces' do
- before do
- ActiveRecord::Base.observers.enable(:user_observer)
- @user = create :user
- @project = create :project, namespace: @user.namespace
- end
-
- it { @user.authorized_projects.should include(@project) }
- it { @user.my_own_projects.should include(@project) }
- it { @user.several_namespaces?.should be_false }
- end
end
diff --git a/spec/roles/account_role_spec.rb b/spec/roles/account_role_spec.rb
new file mode 100644
index 00000000000..4b214551453
--- /dev/null
+++ b/spec/roles/account_role_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe User, "Account" do
+ describe 'normal user' do
+ let(:user) { create(:user, name: 'John Smith') }
+
+ it { user.is_admin?.should be_false }
+ it { user.require_ssh_key?.should be_true }
+ it { user.can_create_group?.should be_false }
+ it { user.can_create_project?.should be_true }
+ it { user.first_name.should == 'John' }
+ end
+
+ describe 'blocking user' do
+ let(:user) { create(:user, name: 'John Smith') }
+
+ it "should block user" do
+ user.block
+ user.blocked.should be_true
+ end
+ end
+
+ describe 'projects' do
+ before do
+ ActiveRecord::Base.observers.enable(:user_observer)
+ @user = create :user
+ @project = create :project, namespace: @user.namespace
+ end
+
+ it { @user.authorized_projects.should include(@project) }
+ it { @user.my_own_projects.should include(@project) }
+ end
+
+ describe 'namespaced' do
+ before do
+ ActiveRecord::Base.observers.enable(:user_observer)
+ @user = create :user
+ @project = create :project, namespace: @user.namespace
+ end
+
+ it { @user.several_namespaces?.should be_false }
+ it { @user.namespaces.should == [@user.namespace] }
+ end
+end