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) }
|
2015-11-20 09:48:05 -05:00
|
|
|
let(:group) { create(:group) }
|
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
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
let(:finder) { described_class.new }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
describe 'without a group' do
|
|
|
|
describe 'without a user' do
|
|
|
|
subject { finder.execute }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
it { is_expected.to eq([public_project]) }
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
describe 'with a user' do
|
|
|
|
subject { finder.execute(user) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
describe 'without private projects' do
|
|
|
|
it { is_expected.to eq([public_project, internal_project]) }
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
describe 'with private projects' do
|
|
|
|
before do
|
|
|
|
private_project.team.add_user(user, Gitlab::Access::MASTER)
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
it do
|
|
|
|
is_expected.to eq([public_project, internal_project,
|
|
|
|
private_project])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with a group' do
|
|
|
|
describe 'without a user' do
|
|
|
|
subject { finder.execute(nil, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
it { is_expected.to eq([public_project]) }
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
describe 'with a user' do
|
|
|
|
subject { finder.execute(user, group: group) }
|
2014-02-25 07:36:36 -05:00
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
it { is_expected.to eq([public_project, internal_project]) }
|
|
|
|
end
|
|
|
|
end
|
2014-02-25 07:36:36 -05:00
|
|
|
end
|
|
|
|
end
|