Commit e63d62f7 authored by James Lopez's avatar James Lopez

Merge branch 'fix_constraints_for_sse' into 'master'

Fix constraints for the Static Site Editor route

See merge request gitlab-org/gitlab!29496
parents 62430397 8ebd2bc8
......@@ -26,10 +26,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
scope '-' do
get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
scope controller: :static_site_editor do
get '/sse/*id', action: :show, as: :show_sse
end
resources :artifacts, only: [:index, :destroy]
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
......
......@@ -21,6 +21,9 @@ resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
end
end
# NOTE: Add new routes to repository_scoped.rb instead (see
# https://docs.gitlab.com/ee/development/routing.html#project-routes).
#
# Don't use format parameter as file extension (old 3.0.x behavior)
# See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
scope format: false do
......
......@@ -30,5 +30,11 @@ scope format: false do
resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex }
resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
scope constraints: { id: /[^\0]+/ } do
scope controller: :static_site_editor do
get '/sse/*id', action: :show, as: :show_sse
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Static Site Editor' do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
before do
project.add_maintainer(user)
sign_in(user)
visit project_show_sse_path(project, 'master/README.md')
end
it 'renders Static Site Editor page' do
expect(page).to have_selector('#static-site-editor')
end
end
......@@ -838,6 +838,13 @@ describe 'project routing' do
end
end
describe Projects::StaticSiteEditorController, 'routing' do
it 'routes to static_site_editor#show', :aggregate_failures do
expect(get('/gitlab/gitlabhq/-/sse/master/CONTRIBUTING.md')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
expect(get('/gitlab/gitlabhq/-/sse/master/README')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/README')
end
end
describe Projects::EnvironmentsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/environments", "/gitlab/gitlabhq/-/environments"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment