2015-11-18 06:21:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ContributedProjectsFinder do
|
|
|
|
let(:source_user) { create(:user) }
|
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
let(:finder) { described_class.new(source_user) }
|
|
|
|
|
2017-01-25 16:49:52 -05:00
|
|
|
let!(:public_project) { create(:empty_project, :public) }
|
|
|
|
let!(:private_project) { create(:empty_project, :private) }
|
2015-11-18 06:21:06 -05:00
|
|
|
|
|
|
|
before do
|
2017-01-29 17:37:24 -05:00
|
|
|
private_project.add_master(source_user)
|
|
|
|
private_project.add_developer(current_user)
|
|
|
|
public_project.add_master(source_user)
|
2015-11-18 06:21:06 -05:00
|
|
|
|
2017-01-29 17:37:24 -05:00
|
|
|
create(:event, :pushed, project: public_project, target: public_project, author: source_user)
|
|
|
|
create(:event, :pushed, project: private_project, target: private_project, author: source_user)
|
2015-11-18 06:21:06 -05:00
|
|
|
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
|