2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-11 04:26:04 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'User explores projects' do
|
2020-02-26 18:09:24 +00:00
|
|
|
let_it_be(:archived_project) { create(:project, :archived) }
|
|
|
|
let_it_be(:internal_project) { create(:project, :internal) }
|
|
|
|
let_it_be(:private_project) { create(:project, :private) }
|
|
|
|
let_it_be(:public_project) { create(:project, :public) }
|
2017-10-11 04:26:04 +00:00
|
|
|
|
|
|
|
context 'when not signed in' do
|
|
|
|
context 'when viewing public projects' do
|
|
|
|
before do
|
|
|
|
visit(explore_projects_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'shows public projects'
|
|
|
|
end
|
2020-04-15 15:09:17 +00:00
|
|
|
|
|
|
|
context 'when visibility is restricted to public' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
|
|
|
|
visit(explore_projects_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to login page' do
|
|
|
|
expect(page).to have_current_path(new_user_session_path)
|
|
|
|
end
|
|
|
|
end
|
2017-10-11 04:26:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed in' do
|
2020-02-26 18:09:24 +00:00
|
|
|
let_it_be(:user) { create(:user) }
|
2017-10-11 04:26:04 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when viewing public projects' do
|
|
|
|
before do
|
|
|
|
visit(explore_projects_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'shows public and internal projects'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when viewing most starred projects' do
|
|
|
|
before do
|
|
|
|
visit(starred_explore_projects_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'shows public and internal projects'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when viewing trending projects' do
|
|
|
|
before do
|
|
|
|
[archived_project, public_project].each { |project| create(:note_on_issue, project: project) }
|
|
|
|
|
|
|
|
TrendingProject.refresh!
|
|
|
|
|
|
|
|
visit(trending_explore_projects_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'shows public projects'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|