diff options
Diffstat (limited to 'spec/routing')
-rw-r--r-- | spec/routing/git_http_routing_spec.rb | 58 | ||||
-rw-r--r-- | spec/routing/routing_spec.rb | 4 |
2 files changed, 48 insertions, 14 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 diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 76ccdf3237c..73d20cad4dd 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -54,10 +54,6 @@ RSpec.describe "Mounted Apps", "routing" do it "to API" do expect(get("/api/issues")).to be_routable end - - it "to Grack" do - expect(get("/gitlab/gitlabhq.git")).to be_routable - end end # snippets GET /snippets(.:format) snippets#index |