debian-mirror-gitlab/spec/routing/git_http_routing_spec.rb

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

84 lines
2.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'git_http routing' do
2021-02-22 17:27:13 +05:30
describe 'code repositories' do
it_behaves_like 'git repository routes' do
let(:path) { '/gitlab-org/gitlab-test.git' }
end
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
let(:path) { '/gitlab-org/gitlab-test.git' }
end
end
describe 'wiki repositories' do
context 'in project' do
let(:path) { '/gitlab-org/gitlab-test.wiki.git' }
2019-10-12 21:52:04 +05:30
2021-02-22 17:27:13 +05:30
it_behaves_like 'git repository routes'
it_behaves_like 'git repository routes with fallback for git-upload-pack'
2019-10-12 21:52:04 +05:30
2021-02-22 17:27:13 +05:30
describe 'redirects', type: :request do
let(:web_path) { '/gitlab-org/gitlab-test/-/wikis' }
it 'redirects namespace/project.wiki.git to the project wiki' do
expect(get(path)).to redirect_to(web_path)
end
it 'preserves query parameters' do
expect(get("#{path}?foo=bar&baz=qux")).to redirect_to("#{web_path}?foo=bar&baz=qux")
end
it 'only redirects when the format is .git' do
expect(get(path.delete_suffix('.git'))).not_to redirect_to(web_path)
expect(get(path.delete_suffix('.git') + '.json')).not_to redirect_to(web_path)
end
end
2019-10-12 21:52:04 +05:30
end
2021-02-22 17:27:13 +05:30
context 'in toplevel group' do
it_behaves_like 'git repository routes' do
let(:path) { '/gitlab-org.wiki.git' }
end
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
let(:path) { '/gitlab-org.wiki.git' }
end
2019-10-12 21:52:04 +05:30
end
2021-02-22 17:27:13 +05:30
context 'in child group' do
it_behaves_like 'git repository routes' do
let(:path) { '/gitlab-org/child.wiki.git' }
end
it_behaves_like 'git repository routes with fallback for git-upload-pack' do
let(:path) { '/gitlab-org/child.wiki.git' }
end
end
end
describe 'snippet repositories' do
context 'personal snippet' do
it_behaves_like 'git repository routes' do
let(:path) { '/snippets/123.git' }
end
it_behaves_like 'git repository routes without fallback' do
let(:path) { '/snippets/123.git' }
end
end
context 'project snippet' do
it_behaves_like 'git repository routes' do
let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' }
end
it_behaves_like 'git repository routes with fallback' do
let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' }
end
2019-10-12 21:52:04 +05:30
end
end
end