diff options
Diffstat (limited to 'spec/routing/project_routing_spec.rb')
-rw-r--r-- | spec/routing/project_routing_spec.rb | 197 |
1 files changed, 136 insertions, 61 deletions
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index abc42d11c63..82d58d12607 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -211,11 +211,20 @@ RSpec.describe 'project routing' do expect(get('/gitlab/gitlabhq/-/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') expect(get('/gitlab/gitlabhq/-/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz') expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss') - assert_routing({ path: "/gitlab/gitlabhq/-/refs/stable/logs_tree/new%0A%0Aline.txt", - method: :get }, - { controller: 'projects/refs', action: 'logs_tree', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "stable", path: "new\n\nline.txt" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/refs/stable/logs_tree/new%0A%0Aline.txt", + method: :get + }, + { + controller: 'projects/refs', + action: 'logs_tree', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "stable", + path: "new\n\nline.txt" + } + ) end it_behaves_like 'redirecting a legacy path', '/gitlab/gitlabhq/refs/switch', '/gitlab/gitlabhq/-/refs/switch' @@ -498,11 +507,19 @@ RSpec.describe 'project routing' do expect(get('/gitlab/gitlabhq/-/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/blame/master/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/blame', action: 'show', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "master/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/blame/master/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/blame', + action: 'show', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "master/#{newline_file}" + } + ) end it 'to #streaming' do @@ -525,11 +542,19 @@ RSpec.describe 'project routing' do expect(get('/gitlab/gitlabhq/-/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/blob/blob/master/blob/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/blob', action: 'show', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "blob/master/blob/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/blob/blob/master/blob/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/blob', + action: 'show', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "blob/master/blob/#{newline_file}" + } + ) end it 'to #show from unscoped routing' do @@ -546,11 +571,19 @@ RSpec.describe 'project routing' do expect(get('/gitlab/gitlabhq/-/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/tree/master/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/tree', action: 'show', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "master/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/tree/master/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/tree', + action: 'show', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "master/#{newline_file}" + } + ) end it 'to #show from unscoped routing' do @@ -566,22 +599,38 @@ RSpec.describe 'project routing' do expect(get('/gitlab/gitlabhq/-/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/find_file/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/find_file', action: 'show', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: newline_file.to_s }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/find_file/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/find_file', + action: 'show', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: newline_file.to_s + } + ) end it 'to #list' do expect(get('/gitlab/gitlabhq/-/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/files/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/find_file', action: 'list', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: newline_file.to_s }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/files/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/find_file', + action: 'list', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: newline_file.to_s + } + ) end it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/find_file", "/gitlab/gitlabhq/-/find_file" @@ -591,30 +640,44 @@ RSpec.describe 'project routing' do describe Projects::BlobController, 'routing' do it 'to #edit' do expect(get('/gitlab/gitlabhq/-/edit/master/app/models/project.rb')).to( - route_to('projects/blob#edit', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: 'master/app/models/project.rb')) + route_to('projects/blob#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + ) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/blob', action: 'edit', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "master/docs/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/blob', + action: 'edit', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "master/docs/#{newline_file}" + } + ) end it 'to #preview' do expect(post('/gitlab/gitlabhq/-/preview/master/app/models/project.rb')).to( - route_to('projects/blob#preview', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: 'master/app/models/project.rb')) + route_to('projects/blob#preview', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + ) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/blob', action: 'edit', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "master/docs/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/blob', + action: 'edit', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "master/docs/#{newline_file}" + } + ) end it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/new/master", "/gitlab/gitlabhq/-/new/master" @@ -626,11 +689,19 @@ RSpec.describe 'project routing' do it 'to #show' do newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/-/raw/master/#{url_encoded_newline_file}", - method: :get }, - { controller: 'projects/raw', action: 'show', - namespace_id: 'gitlab', project_id: 'gitlabhq', - id: "master/#{newline_file}" }) + assert_routing( + { + path: "/gitlab/gitlabhq/-/raw/master/#{url_encoded_newline_file}", + method: :get + }, + { + controller: 'projects/raw', + action: 'show', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + id: "master/#{newline_file}" + } + ) end it 'to #show from unscoped routing' do @@ -743,20 +814,24 @@ RSpec.describe 'project routing' do describe '#destroy' do it 'correctly routes to a destroy action' do expect(delete('/gitlab/gitlabhq/registry/repository/1/tags/rc1')) - .to route_to('projects/registry/tags#destroy', - namespace_id: 'gitlab', - project_id: 'gitlabhq', - repository_id: '1', - id: 'rc1') + .to route_to( + 'projects/registry/tags#destroy', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + repository_id: '1', + id: 'rc1' + ) end it 'takes registry tag name constrains into account' do expect(delete('/gitlab/gitlabhq/registry/repository/1/tags/-rc1')) - .not_to route_to('projects/registry/tags#destroy', - namespace_id: 'gitlab', - project_id: 'gitlabhq', - repository_id: '1', - id: '-rc1') + .not_to route_to( + 'projects/registry/tags#destroy', + namespace_id: 'gitlab', + project_id: 'gitlabhq', + repository_id: '1', + id: '-rc1' + ) end end end |