2014-02-25 07:36:36 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-02-25 12:21:53 -05:00
|
|
|
describe ProjectsFinder do
|
2015-11-18 06:21:06 -05:00
|
|
|
describe '#execute' do
|
|
|
|
let(:user) { create(:user) }
|
2016-03-21 19:09:20 -04:00
|
|
|
let(:group) { create(:group, :public) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-20 09:48:05 -05:00
|
|
|
let!(:private_project) do
|
|
|
|
create(:project, :private, name: 'A', path: 'A')
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:internal_project) do
|
|
|
|
create(:project, :internal, group: group, name: 'B', path: 'B')
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:public_project) do
|
|
|
|
create(:project, :public, group: group, name: 'C', path: 'C')
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2016-03-12 08:45:14 -05:00
|
|
|
let!(:shared_project) do
|
|
|
|
create(:project, :private, name: 'D', path: 'D')
|
|
|
|
end
|
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
let(:finder) { described_class.new }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
describe 'without a user' do
|
|
|
|
subject { finder.execute }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
it { is_expected.to eq([public_project]) }
|
2015-11-18 06:21:06 -05:00
|
|
|
end
|
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
describe 'with a user' do
|
|
|
|
subject { finder.execute(user) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
describe 'without private projects' do
|
|
|
|
it { is_expected.to eq([public_project, internal_project]) }
|
2015-11-18 06:21:06 -05:00
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
describe 'with private projects' do
|
|
|
|
before do
|
|
|
|
private_project.team.add_user(user, Gitlab::Access::MASTER)
|
2016-03-12 08:45:14 -05:00
|
|
|
end
|
|
|
|
|
2016-08-12 11:14:39 -04:00
|
|
|
it do
|
|
|
|
is_expected.to eq([public_project, internal_project, private_project])
|
2016-03-12 08:45:14 -05:00
|
|
|
end
|
2015-11-18 06:21:06 -05:00
|
|
|
end
|
|
|
|
end
|
2016-08-12 11:30:44 -04:00
|
|
|
|
|
|
|
describe 'with project_ids_relation' do
|
|
|
|
let(:project_ids_relation) { Project.where(id: internal_project.id) }
|
|
|
|
|
|
|
|
subject { finder.execute(user, project_ids_relation) }
|
|
|
|
|
|
|
|
it { is_expected.to eq([internal_project]) }
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
end
|