2015-11-18 11:21:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PersonalProjectsFinder do
|
2016-03-18 12:28:16 +00:00
|
|
|
let(:source_user) { create(:user) }
|
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
let(:finder) { described_class.new(source_user) }
|
2017-01-25 21:49:52 +00:00
|
|
|
let!(:public_project) { create(:empty_project, :public, namespace: source_user.namespace) }
|
2015-11-18 11:21:06 +00:00
|
|
|
|
|
|
|
let!(:private_project) do
|
2017-01-25 21:49:52 +00:00
|
|
|
create(:empty_project, :private, namespace: source_user.namespace, path: 'mepmep')
|
2015-11-18 11:21:06 +00:00
|
|
|
end
|
|
|
|
|
2016-03-17 22:42:46 +00:00
|
|
|
let!(:internal_project) do
|
2017-01-25 21:49:52 +00:00
|
|
|
create(:empty_project, :internal, namespace: source_user.namespace, path: 'C')
|
2016-03-17 22:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-11-18 11:21:06 +00:00
|
|
|
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) }
|
|
|
|
|
2016-03-17 22:42:46 +00:00
|
|
|
context 'normal user' do
|
|
|
|
it { is_expected.to eq([internal_project, private_project, public_project]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'external' do
|
2017-06-14 18:18:56 +00:00
|
|
|
before do
|
|
|
|
current_user.update_attributes(external: true)
|
|
|
|
end
|
2016-03-17 22:42:46 +00:00
|
|
|
|
|
|
|
it { is_expected.to eq([private_project, public_project]) }
|
|
|
|
end
|
2015-11-18 11:21:06 +00:00
|
|
|
end
|
|
|
|
end
|