Merge branch '44780-wiki-page-with-a-dot-inside-title-slug-leads-to-404-in-the-api' into 'master'

Support Wiki pages with dots in slugs

Closes #44780

See merge request gitlab-org/gitlab-ce!24383
This commit is contained in:
Douwe Maan 2019-01-15 16:28:07 +00:00
commit 267ce96e36
4 changed files with 11 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
title: 'API: Support dots in wiki slugs'
merge_request: 24383
author: Robert Schilling
type: fixed

View file

@ -22,7 +22,9 @@ module API
end
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
WIKI_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(slug: API::NO_SLASH_URL_PART_REGEX)
resource :projects, requirements: WIKI_ENDPOINT_REQUIREMENTS do
desc 'Get a list of wiki pages' do
success Entities::WikiPageBasic
end
@ -103,7 +105,7 @@ module API
requires :file, type: ::API::Validations::Types::SafeFile, desc: 'The attachment file to be uploaded'
optional :branch, type: String, desc: 'The name of the branch'
end
post ":id/wikis/attachments", requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
post ":id/wikis/attachments" do
authorize! :create_wiki, user_project
result = ::Wikis::CreateAttachmentService.new(user_project,

View file

@ -5,7 +5,7 @@ FactoryBot.define do
transient do
attrs do
{
title: 'Title',
title: 'Title.with.dot',
content: 'Content for wiki page',
format: 'markdown'
}

View file

@ -22,7 +22,7 @@ describe API::Wikis do
context 'when wiki has pages' do
let!(:pages) do
[create(:wiki_page, wiki: project_wiki, attrs: { title: 'page1', content: 'content of page1' }),
create(:wiki_page, wiki: project_wiki, attrs: { title: 'page2', content: 'content of page2' })]
create(:wiki_page, wiki: project_wiki, attrs: { title: 'page2.with.dot', content: 'content of page2' })]
end
it 'returns the list of wiki pages without content' do