BigW Consortium Gitlab

contributed_projects_finder_spec.rb 1.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require 'spec_helper'

describe ContributedProjectsFinder do
  let(:source_user) { create(:user) }
  let(:current_user) { create(:user) }

  let(:finder) { described_class.new(source_user) }

  let!(:public_project) { create(:project, :public) }
  let!(:private_project) { create(:project, :private) }

  before do
    private_project.team << [source_user, Gitlab::Access::MASTER]
    private_project.team << [current_user, Gitlab::Access::DEVELOPER]
    public_project.team << [source_user, Gitlab::Access::MASTER]

    create(:event, action: Event::PUSHED, project: public_project,
18
                   target: public_project, author: source_user)
19 20

    create(:event, action: Event::PUSHED, project: private_project,
21
                   target: private_project, author: source_user)
22 23 24 25 26 27 28 29 30 31 32 33 34 35
  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) }

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