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

55 lines
1.7 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'
2020-06-23 00:09:42 +05:30
RSpec.describe ContributedProjectsFinder do
2015-11-26 14:37:03 +05:30
let(:source_user) { create(:user) }
let(:current_user) { create(:user) }
let(:finder) { described_class.new(source_user) }
2017-09-10 17:25:29 +05:30
let!(:public_project) { create(:project, :public) }
let!(:private_project) { create(:project, :private) }
2018-11-20 20:47:30 +05:30
let!(:internal_project) { create(:project, :internal) }
2015-11-26 14:37:03 +05:30
before do
2018-11-18 11:00:15 +05:30
private_project.add_maintainer(source_user)
2017-08-17 22:00:37 +05:30
private_project.add_developer(current_user)
2018-11-18 11:00:15 +05:30
public_project.add_maintainer(source_user)
2015-11-26 14:37:03 +05:30
2017-09-10 17:25:29 +05:30
create(:push_event, project: public_project, author: source_user)
create(:push_event, project: private_project, author: source_user)
2018-11-20 20:47:30 +05:30
create(:push_event, project: internal_project, author: source_user)
2015-11-26 14:37:03 +05:30
end
2018-11-20 20:47:30 +05:30
describe 'activity without a current user' do
2022-08-13 15:12:31 +05:30
it 'does only return public projects' do
projects = finder.execute
expect(projects).to match_array([public_project])
end
2015-11-26 14:37:03 +05:30
2022-08-13 15:12:31 +05:30
it 'does return all projects when visibility gets ignored' do
projects = finder.execute(ignore_visibility: true)
expect(projects).to match_array([private_project, internal_project, public_project])
end
2015-11-26 14:37:03 +05:30
end
2018-11-20 20:47:30 +05:30
describe 'activity with a current user' do
2015-11-26 14:37:03 +05:30
subject { finder.execute(current_user) }
2018-11-20 20:47:30 +05:30
it { is_expected.to match_array([private_project, internal_project, public_project]) }
2015-11-26 14:37:03 +05:30
end
2019-02-02 18:00:53 +05:30
context 'user with private profile' do
it 'does not return contributed projects' do
private_user = create(:user, private_profile: true)
public_project.add_maintainer(private_user)
create(:push_event, project: public_project, author: private_user)
projects = described_class.new(private_user).execute(current_user)
expect(projects).to be_empty
end
end
2015-11-26 14:37:03 +05:30
end