Commit 592412992daf1830fb1df5cc06aac02814c6f911
1 parent
26afde94
Exists in
master
and in
4 other branches
Account role spec
Showing
2 changed files
with
48 additions
and
12 deletions
Show diff stats
spec/models/user_spec.rb
... | ... | @@ -66,6 +66,10 @@ describe User do |
66 | 66 | it { should ensure_length_of(:bio).is_within(0..255) } |
67 | 67 | end |
68 | 68 | |
69 | + describe 'modules' do | |
70 | + it { should include_module(Account) } | |
71 | + end | |
72 | + | |
69 | 73 | describe "Respond to" do |
70 | 74 | it { should respond_to(:is_admin?) } |
71 | 75 | it { should respond_to(:identifier) } |
... | ... | @@ -115,16 +119,4 @@ describe User do |
115 | 119 | user.authentication_token.should_not be_blank |
116 | 120 | end |
117 | 121 | end |
118 | - | |
119 | - describe 'projects and namespaces' do | |
120 | - before do | |
121 | - ActiveRecord::Base.observers.enable(:user_observer) | |
122 | - @user = create :user | |
123 | - @project = create :project, namespace: @user.namespace | |
124 | - end | |
125 | - | |
126 | - it { @user.authorized_projects.should include(@project) } | |
127 | - it { @user.my_own_projects.should include(@project) } | |
128 | - it { @user.several_namespaces?.should be_false } | |
129 | - end | |
130 | 122 | end | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe User, "Account" do | |
4 | + describe 'normal user' do | |
5 | + let(:user) { create(:user, name: 'John Smith') } | |
6 | + | |
7 | + it { user.is_admin?.should be_false } | |
8 | + it { user.require_ssh_key?.should be_true } | |
9 | + it { user.can_create_group?.should be_false } | |
10 | + it { user.can_create_project?.should be_true } | |
11 | + it { user.first_name.should == 'John' } | |
12 | + end | |
13 | + | |
14 | + describe 'blocking user' do | |
15 | + let(:user) { create(:user, name: 'John Smith') } | |
16 | + | |
17 | + it "should block user" do | |
18 | + user.block | |
19 | + user.blocked.should be_true | |
20 | + end | |
21 | + end | |
22 | + | |
23 | + describe 'projects' do | |
24 | + before do | |
25 | + ActiveRecord::Base.observers.enable(:user_observer) | |
26 | + @user = create :user | |
27 | + @project = create :project, namespace: @user.namespace | |
28 | + end | |
29 | + | |
30 | + it { @user.authorized_projects.should include(@project) } | |
31 | + it { @user.my_own_projects.should include(@project) } | |
32 | + end | |
33 | + | |
34 | + describe 'namespaced' do | |
35 | + before do | |
36 | + ActiveRecord::Base.observers.enable(:user_observer) | |
37 | + @user = create :user | |
38 | + @project = create :project, namespace: @user.namespace | |
39 | + end | |
40 | + | |
41 | + it { @user.several_namespaces?.should be_false } | |
42 | + it { @user.namespaces.should == [@user.namespace] } | |
43 | + end | |
44 | +end | ... | ... |