debian-mirror-gitlab/spec/features/explore/groups_spec.rb

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

114 lines
3.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Explore Groups', :js, feature_category: :subgroups do
2018-03-17 18:26:18 +05:30
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
shared_examples 'renders public and internal projects' do
it do
visit_page
2023-07-09 08:55:56 +05:30
expect(page).to have_content(public_project.name).or(have_content(public_project.path))
expect(page).to have_content(internal_project.name).or(have_content(internal_project.path))
2018-03-17 18:26:18 +05:30
expect(page).not_to have_content(private_project.name)
end
end
shared_examples 'renders only public project' do
it do
visit_page
2023-07-09 08:55:56 +05:30
expect(page).to have_content(public_project.name).or(have_content(public_project.path))
2018-03-17 18:26:18 +05:30
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
2023-07-09 08:55:56 +05:30
expect(page).to have_content(group.path)
2018-03-17 18:26:18 +05:30
end
end
context 'when signed in' do
before do
sign_in(user)
end
2023-07-09 08:55:56 +05:30
context 'for group_path' do
it_behaves_like 'renders public and internal projects' do
subject(:visit_page) { visit group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'for issues_group_path' do
it_behaves_like 'renders public and internal projects' do
subject(:visit_page) { visit issues_group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'for merge_requests_group_path' do
it_behaves_like 'renders public and internal projects' do
subject(:visit_page) { visit merge_requests_group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
it_behaves_like 'renders group in public groups area'
end
context 'when signed out' do
2023-07-09 08:55:56 +05:30
context 'for group_path' do
it_behaves_like 'renders only public project' do
subject(:visit_page) { visit group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'for issues_group_path' do
it_behaves_like 'renders only public project' do
subject(:visit_page) { visit issues_group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'for merge_requests_group_path' do
it_behaves_like 'renders only public project' do
subject(:visit_page) { visit merge_requests_group_path(group) }
end
2018-03-17 18:26:18 +05:30
end
it_behaves_like 'renders group in public groups area'
2020-04-22 19:07:51 +05:30
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
2018-03-17 18:26:18 +05:30
end
end