summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9673854da53..f0a6012d0c2 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -106,11 +106,33 @@ describe User do
ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user
@project = create :project, namespace: @user.namespace
+ @project_2 = create :project # Grant MASTER access to the user
+ @project_3 = create :project # Grant DEVELOPER access to the user
+
+ UsersProject.add_users_into_projects(
+ [@project_2.id], [@user.id], UsersProject::MASTER
+ )
+ UsersProject.add_users_into_projects(
+ [@project_3.id], [@user.id], UsersProject::DEVELOPER
+ )
end
it { @user.authorized_projects.should include(@project) }
+ it { @user.authorized_projects.should include(@project_2) }
+ it { @user.authorized_projects.should include(@project_3) }
it { @user.owned_projects.should include(@project) }
+ it { @user.owned_projects.should_not include(@project_2) }
+ it { @user.owned_projects.should_not include(@project_3) }
it { @user.personal_projects.should include(@project) }
+ it { @user.personal_projects.should_not include(@project_2) }
+ it { @user.personal_projects.should_not include(@project_3) }
+
+ # master_projects doesn't check creator/namespace.
+ # In real case the users_projects relation will certainly be assigned
+ # when the project is created.
+ it { @user.master_projects.should_not include(@project) }
+ it { @user.master_projects.should include(@project_2) }
+ it { @user.master_projects.should_not include(@project_3) }
end
describe 'groups' do