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

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

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

F
Felipe Artur 已提交
13
  let!(:internal_project) do
14
    create(:empty_project, :internal, namespace: source_user.namespace, path: 'C')
F
Felipe Artur 已提交
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) }

F
Felipe Artur 已提交
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