summaryrefslogtreecommitdiff
path: root/spec/routing/project_routing_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/routing/project_routing_spec.rb')
-rw-r--r--spec/routing/project_routing_spec.rb82
1 files changed, 72 insertions, 10 deletions
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index 87091da0c84..b80baf0aa13 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -314,39 +314,39 @@ RSpec.describe 'project routing' do
# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
describe SnippetsController, 'routing' do
it 'to #raw' do
- expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/-/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it 'to #index' do
- expect(get('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ expect(get('/gitlab/gitlabhq/-/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
it 'to #create' do
- expect(post('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ expect(post('/gitlab/gitlabhq/-/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
it 'to #new' do
- expect(get('/gitlab/gitlabhq/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ expect(get('/gitlab/gitlabhq/-/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
it 'to #edit' do
- expect(get('/gitlab/gitlabhq/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/-/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it 'to #show' do
- expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it 'to #update' do
- expect(put('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ expect(put('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it 'to #destroy' do
- expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ expect(delete('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
- it 'to #show from scope routing' do
- expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it 'to #show from unscope routing' do
+ expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
end
@@ -823,4 +823,66 @@ RSpec.describe 'project routing' do
project_id: 'gitlabhq', snippet_id: '1', ref: 'master', path: 'lib/version.rb')
end
end
+
+ describe Projects::MetricsDashboardController, 'routing' do
+ it 'routes to #show with no dashboard_path and no page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics").to route_to(
+ "projects/metrics_dashboard#show",
+ **base_params
+ )
+ end
+
+ it 'routes to #show with only dashboard_path' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/dashboard1.yml").to route_to(
+ "projects/metrics_dashboard#show",
+ dashboard_path: 'dashboard1.yml',
+ **base_params
+ )
+ end
+
+ it 'routes to #show with only page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/panel/new").to route_to(
+ "projects/metrics_dashboard#show",
+ page: 'panel/new',
+ **base_params
+ )
+ end
+
+ it 'routes to #show with dashboard_path and page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/config%2Fprometheus%2Fcommon_metrics.yml/panel/new").to route_to(
+ "projects/metrics_dashboard#show",
+ dashboard_path: 'config/prometheus/common_metrics.yml',
+ page: 'panel/new',
+ **base_params
+ )
+ end
+
+ it 'routes to 404 with invalid page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/invalid_page").to route_to(
+ 'application#route_not_found',
+ unmatched_route: 'gitlab/gitlabhq/-/metrics/invalid_page'
+ )
+ end
+
+ it 'routes to 404 with invalid dashboard_path' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/invalid_dashboard").to route_to(
+ 'application#route_not_found',
+ unmatched_route: 'gitlab/gitlabhq/-/metrics/invalid_dashboard'
+ )
+ end
+
+ it 'routes to 404 with invalid dashboard_path and valid page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/dashboard1/panel/new").to route_to(
+ 'application#route_not_found',
+ unmatched_route: 'gitlab/gitlabhq/-/metrics/dashboard1/panel/new'
+ )
+ end
+
+ it 'routes to 404 with valid dashboard_path and invalid page' do
+ expect(get: "/gitlab/gitlabhq/-/metrics/dashboard1.yml/invalid_page").to route_to(
+ 'application#route_not_found',
+ unmatched_route: 'gitlab/gitlabhq/-/metrics/dashboard1.yml/invalid_page'
+ )
+ end
+ end
end