2019-10-16 05:07:51 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PersonalProjectsFinder do
|
2016-03-18 08:28:16 -04:00
|
|
|
let(:source_user) { create(:user) }
|
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
let(:finder) { described_class.new(source_user) }
|
2018-04-05 10:56:32 -04:00
|
|
|
let!(:public_project) do
|
|
|
|
create(:project, :public, namespace: source_user.namespace, updated_at: 1.hour.ago)
|
|
|
|
end
|
2015-11-18 06:21:06 -05:00
|
|
|
|
|
|
|
let!(:private_project) do
|
2018-04-05 10:56:32 -04:00
|
|
|
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep')
|
2015-11-18 06:21:06 -05:00
|
|
|
end
|
|
|
|
|
2016-03-17 18:42:46 -04:00
|
|
|
let!(:internal_project) do
|
2018-04-05 10:56:32 -04:00
|
|
|
create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C')
|
2016-03-17 18:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-11-18 06:21:06 -05:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
private_project.add_developer(current_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) }
|
|
|
|
|
2016-03-17 18:42:46 -04:00
|
|
|
context 'normal user' do
|
2018-04-05 10:56:32 -04:00
|
|
|
it { is_expected.to eq([public_project, internal_project, private_project]) }
|
2016-03-17 18:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'external' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2018-07-02 06:43:06 -04:00
|
|
|
current_user.update(external: true)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2016-03-17 18:42:46 -04:00
|
|
|
|
2018-04-05 10:56:32 -04:00
|
|
|
it { is_expected.to eq([public_project, private_project]) }
|
2016-03-17 18:42:46 -04:00
|
|
|
end
|
2015-11-18 06:21:06 -05:00
|
|
|
end
|
|
|
|
end
|