debian-mirror-gitlab/spec/finders/personal_projects_finder_spec.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2015-11-26 14:37:03 +05:30
require 'spec_helper'
describe PersonalProjectsFinder do
2016-06-02 11:05:42 +05:30
let(:source_user) { create(:user) }
let(:current_user) { create(:user) }
let(:finder) { described_class.new(source_user) }
2018-11-08 19:23:39 +05:30
let!(:public_project) do
create(:project, :public, namespace: source_user.namespace, updated_at: 1.hour.ago)
end
2015-11-26 14:37:03 +05:30
2016-06-02 11:05:42 +05:30
let!(:private_project) do
2018-11-08 19:23:39 +05:30
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep')
2015-11-26 14:37:03 +05:30
end
2016-06-02 11:05:42 +05:30
let!(:internal_project) do
2018-11-08 19:23:39 +05:30
create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C')
2015-11-26 14:37:03 +05:30
end
before do
2018-03-17 18:26:18 +05:30
private_project.add_developer(current_user)
2015-11-26 14:37:03 +05:30
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-06-02 11:05:42 +05:30
context 'normal user' do
2018-11-08 19:23:39 +05:30
it { is_expected.to eq([public_project, internal_project, private_project]) }
2016-06-02 11:05:42 +05:30
end
context 'external' do
2017-09-10 17:25:29 +05:30
before do
2018-11-18 11:00:15 +05:30
current_user.update(external: true)
2017-09-10 17:25:29 +05:30
end
2016-06-02 11:05:42 +05:30
2018-11-08 19:23:39 +05:30
it { is_expected.to eq([public_project, private_project]) }
2016-06-02 11:05:42 +05:30
end
2015-11-26 14:37:03 +05:30
end
end