Commit acd8930c authored by Sean McGivern's avatar Sean McGivern
Browse files

Tidy up user project specs

parent 8a185cbe505c
......@@ -383,7 +383,7 @@ def authorized_projects
def viewable_starred_projects
starred_projects.where("projects.visibility_level IN (?) OR projects.id IN (#{projects_union.to_sql})",
[Gitlab::VisibilityLevel::PUBLIC, Gitlab::VisibilityLevel::INTERNAL])
[Project::PUBLIC, Project::INTERNAL])
end
def owned_projects
......
......@@ -233,8 +233,6 @@
@project = create :project, namespace: @user.namespace
@project_2 = create :project, group: create(:group) # Grant MASTER access to the user
@project_3 = create :project, group: create(:group) # Grant DEVELOPER access to the user
@project_4 = create :project, group: create(:group)
@project_5 = create :project, group: create(:group)
@project_2.team << [@user, :master]
@project_3.team << [@user, :developer]
......@@ -787,23 +785,20 @@
describe '#viewable_starred_projects' do
let(:user) { create(:user) }
let(:public_project) { create(:project, :public) }
let(:private_project) { create(:project, :private) }
let(:private_viewable_project) { create(:project, :private) }
let(:viewable?) { -> (project) { user.can?(:read_project, project) } }
let(:projects) { [public_project, private_project, private_viewable_project] }
let(:public_project) { create(:empty_project, :public) }
let(:private_project) { create(:empty_project, :private) }
let(:private_viewable_project) { create(:empty_project, :private) }
before do
private_viewable_project.team << [user, Gitlab::Access::MASTER]
projects.each { |project| user.toggle_star(project) }
end
it 'returns only starred projects the user can view' do
expect(user.viewable_starred_projects).to all(satisfy(&viewable?))
[public_project, private_project, private_viewable_project].each do |project|
user.toggle_star(project)
end
end
it 'rejects only starred projects the user can not view' do
expect(projects - user.viewable_starred_projects).not_to include(satisfy(&viewable?))
it 'returns only starred projects the user can view' do
expect(user.viewable_starred_projects).not_to include(private_project)
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment