BigW Consortium Gitlab

personal_projects_finder_spec.rb 1.09 KB
Newer Older
1 2 3
require 'spec_helper'

describe PersonalProjectsFinder do
4 5 6 7
  let(:source_user)     { create(:user) }
  let(:current_user)    { create(:user) }
  let(:finder)          { described_class.new(source_user) }
  let!(:public_project) { create(:project, :public, namespace: source_user.namespace) }
8 9

  let!(:private_project) do
10
    create(:project, :private, namespace: source_user.namespace, path: 'mepmep')
11 12
  end

Felipe Artur committed
13
  let!(:internal_project) do
14
    create(:project, :internal, namespace: source_user.namespace, path: 'C')
Felipe Artur committed
15 16
  end

17 18 19 20 21 22 23 24 25 26 27 28 29
  before do
    private_project.team << [current_user, Gitlab::Access::DEVELOPER]
  end

  describe 'without a current user' do
    subject { finder.execute }

    it { is_expected.to eq([public_project]) }
  end

  describe 'with a current user' do
    subject { finder.execute(current_user) }

Felipe Artur committed
30 31 32 33 34 35 36 37 38
    context 'normal user' do
      it { is_expected.to eq([internal_project, private_project, public_project]) }
    end

    context 'external' do
      before { current_user.update_attributes(external: true) }

      it { is_expected.to eq([private_project, public_project]) }
    end
39 40
  end
end