diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 15:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 15:09:17 +0300 |
commit | 7b2635a55d4e87431bae752bd44c6fd2d2657b03 (patch) | |
tree | 88182aabb51a167e10f6c3a6d404b2247613047f /spec/routing/git_http_routing_spec.rb | |
parent | a7704bf16a51a8c993215a69db17232e3f246b8e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/routing/git_http_routing_spec.rb')
-rw-r--r-- | spec/routing/git_http_routing_spec.rb | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/spec/routing/git_http_routing_spec.rb b/spec/routing/git_http_routing_spec.rb index e5216d99eb9..e3cc1440a9e 100644 --- a/spec/routing/git_http_routing_spec.rb +++ b/spec/routing/git_http_routing_spec.rb @@ -3,22 +3,60 @@ require 'spec_helper' RSpec.describe 'git_http routing' do - include RSpec::Rails::RequestExampleGroup + describe 'code repositories' do + it_behaves_like 'git repository routes' 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' } + + it_behaves_like 'git repository routes' + + 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 - describe 'wiki.git routing', 'routing' do - let(:wiki_path) { '/gitlab/gitlabhq/wikis' } + it 'preserves query parameters' do + expect(get("#{path}?foo=bar&baz=qux")).to redirect_to("#{web_path}?foo=bar&baz=qux") + end - it 'redirects namespace/project.wiki.git to the project wiki' do - expect(get('/gitlab/gitlabhq.wiki.git')).to redirect_to(wiki_path) + 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 end - it 'preserves query parameters' do - expect(get('/gitlab/gitlabhq.wiki.git?foo=bar&baz=qux')).to redirect_to("#{wiki_path}?foo=bar&baz=qux") + context 'in toplevel group' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org.wiki.git' } + end + end + + context 'in child group' do + it_behaves_like 'git repository routes' 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 end - it 'only redirects when the format is .git' do - expect(get('/gitlab/gitlabhq.wiki')).not_to redirect_to(wiki_path) - expect(get('/gitlab/gitlabhq.wiki.json')).not_to redirect_to(wiki_path) + context 'project snippet' do + it_behaves_like 'git repository routes' do + let(:path) { '/gitlab-org/gitlab-test/snippets/123.git' } + end end end end |