2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-24 12:46:30 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Explore Groups', :js do
|
|
|
|
let(:user) { create :user }
|
|
|
|
let(:group) { create :group }
|
|
|
|
let!(:private_project) do
|
|
|
|
create :project, :private, namespace: group do |project|
|
|
|
|
create(:issue, project: internal_project)
|
|
|
|
create(:merge_request, source_project: project, target_project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:internal_project) do
|
|
|
|
create :project, :internal, namespace: group do |project|
|
|
|
|
create(:issue, project: project)
|
|
|
|
create(:merge_request, source_project: project, target_project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:public_project) do
|
|
|
|
create(:project, :public, namespace: group) do |project|
|
|
|
|
create(:issue, project: project)
|
|
|
|
create(:merge_request, source_project: project, target_project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-06 16:06:44 -05:00
|
|
|
before do
|
|
|
|
stub_feature_flags({ vue_issuables_list: { enabled: false, thing: group } })
|
|
|
|
end
|
|
|
|
|
2017-12-24 12:46:30 -05:00
|
|
|
shared_examples 'renders public and internal projects' do
|
|
|
|
it do
|
|
|
|
visit_page
|
|
|
|
expect(page).to have_content(public_project.name)
|
|
|
|
expect(page).to have_content(internal_project.name)
|
|
|
|
expect(page).not_to have_content(private_project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'renders only public project' do
|
|
|
|
it do
|
|
|
|
visit_page
|
|
|
|
expect(page).to have_content(public_project.name)
|
|
|
|
expect(page).not_to have_content(internal_project.name)
|
|
|
|
expect(page).not_to have_content(private_project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'renders group in public groups area' do
|
|
|
|
it do
|
|
|
|
visit explore_groups_path
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders public and internal projects' do
|
|
|
|
subject(:visit_page) { visit group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders public and internal projects' do
|
|
|
|
subject(:visit_page) { visit issues_group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders public and internal projects' do
|
|
|
|
subject(:visit_page) { visit merge_requests_group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders group in public groups area'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
|
|
|
it_behaves_like 'renders only public project' do
|
|
|
|
subject(:visit_page) { visit group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders only public project' do
|
|
|
|
subject(:visit_page) { visit issues_group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders only public project' do
|
|
|
|
subject(:visit_page) { visit merge_requests_group_path(group) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'renders group in public groups area'
|
2020-04-15 11:09:17 -04:00
|
|
|
|
|
|
|
context 'when visibility is restricted to public' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the sign in page' do
|
|
|
|
visit explore_groups_path
|
|
|
|
|
|
|
|
expect(page).to have_current_path(new_user_session_path)
|
|
|
|
end
|
|
|
|
end
|
2017-12-24 12:46:30 -05:00
|
|
|
end
|
|
|
|
end
|