projects_finder_spec.rb 1.6 KB
Newer Older
1 2
require 'spec_helper'

3
describe ProjectsFinder do
4 5 6 7 8 9 10 11 12
  let(:user) { create :user }
  let(:group) { create :group }

  let(:project1) { create(:empty_project, group: group, visibility_level: Project::PUBLIC) }
  let(:project2) { create(:empty_project, group: group, visibility_level: Project::INTERNAL) }
  let(:project3) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) }
  let(:project4) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) }

  context 'non authenticated' do
13
    subject { ProjectsFinder.new.execute(nil, group: group) }
14 15 16 17 18 19 20 21

    it { should include(project1) }
    it { should_not include(project2) }
    it { should_not include(project3) }
    it { should_not include(project4) }
  end

  context 'authenticated' do
22
    subject { ProjectsFinder.new.execute(user, group: group) }
23 24 25 26 27 28 29 30 31 32

    it { should include(project1) }
    it { should include(project2) }
    it { should_not include(project3) }
    it { should_not include(project4) }
  end

  context 'authenticated, project member' do
    before { project3.team << [user, :developer] }

33
    subject { ProjectsFinder.new.execute(user, group: group) }
34 35 36 37 38 39 40 41 42 43

    it { should include(project1) }
    it { should include(project2) }
    it { should include(project3) }
    it { should_not include(project4) }
  end

  context 'authenticated, group member' do
    before { group.add_user(user, Gitlab::Access::DEVELOPER) }

44
    subject { ProjectsFinder.new.execute(user, group: group) }
45 46 47 48 49 50 51

    it { should include(project1) }
    it { should include(project2) }
    it { should include(project3) }
    it { should include(project4) }
  end
end