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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.3 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe ForkProjectsFinder do
2018-12-13 13:39:08 +05:30
include ProjectForksHelper
let(:source_project) { create(:project, :public, :empty_repo) }
let(:private_fork) { fork_project(source_project, nil, name: 'A') }
let(:internal_fork) { fork_project(source_project, nil, name: 'B') }
let(:public_fork) { fork_project(source_project, nil, name: 'C') }
2018-03-17 18:26:18 +05:30
let(:non_member) { create(:user) }
let(:private_fork_member) { create(:user) }
before do
2018-12-13 13:39:08 +05:30
private_fork.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
2018-03-17 18:26:18 +05:30
private_fork.add_developer(private_fork_member)
2018-12-13 13:39:08 +05:30
internal_fork.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
2018-03-17 18:26:18 +05:30
end
describe '#execute' do
let(:finder) { described_class.new(source_project, params: {}, current_user: current_user) }
subject { finder.execute }
describe 'without a user' do
let(:current_user) { nil }
it { is_expected.to eq([public_fork]) }
end
describe 'with a user' do
let(:current_user) { non_member }
it { is_expected.to eq([public_fork, internal_fork]) }
end
describe 'with a member' do
let(:current_user) { private_fork_member }
it { is_expected.to eq([public_fork, internal_fork, private_fork]) }
end
end
end