blob: 3bbca3ca32bfebff08ac875bf0d4422dd17da7e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "Projects::RedirectController requests" do
using RSpec::Parameterized::TableSyntax
let_it_be(:private_project) { create(:project, :private) }
let_it_be(:public_project) { create(:project, :public) }
let_it_be(:user) { create(:user) }
before_all do
private_project.add_developer(user)
end
describe 'GET redirect_from_id' do
where(:authenticated, :project, :is_found) do
true | ref(:private_project) | true
false | ref(:private_project) | false
true | ref(:public_project) | true
false | ref(:public_project) | true
true | build(:project, id: 0) | false
end
with_them do
before do
sign_in(user) if authenticated
get "/projects/#{project.id}"
end
if params[:is_found]
it 'redirects to the project page' do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(project_path(project))
end
else
it 'gives 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
# This is a regression test for https://gitlab.com/gitlab-org/gitlab/-/issues/351058
context 'with sourcegraph enabled' do
let_it_be(:sourcegraph_url) { 'https://sourcegraph.test' }
before do
allow(Gitlab::CurrentSettings).to receive(:sourcegraph_url).and_return(sourcegraph_url)
allow(Gitlab::CurrentSettings).to receive(:sourcegraph_enabled).and_return(true)
sign_in(user)
end
context 'with projects/:id route' do
subject { get "/projects/#{public_project.id}" }
it 'redirects successfully' do
subject
expect(response).to redirect_to(project_path(public_project))
end
end
end
end
|