Commit bd8fba86 authored by Stan Hu's avatar Stan Hu

Merge branch '209761-fix-wiki-directories-with-hyphens' into 'master'

Fix WikiPage#title_changed for paths with spaces

See merge request gitlab-org/gitlab!27087
parents a6f35904 6eb00b13
...@@ -257,7 +257,7 @@ class WikiPage ...@@ -257,7 +257,7 @@ class WikiPage
def title_changed? def title_changed?
if persisted? if persisted?
old_title, old_dir = wiki.page_title_and_dir(self.class.unhyphenize(@page.url_path)) old_title, old_dir = wiki.page_title_and_dir(self.class.unhyphenize(@page.url_path))
new_title, new_dir = wiki.page_title_and_dir(title) new_title, new_dir = wiki.page_title_and_dir(self.class.unhyphenize(title))
new_title != old_title || (title.include?('/') && new_dir != old_dir) new_title != old_title || (title.include?('/') && new_dir != old_dir)
else else
......
---
title: Fix WikiPage#title_changed for paths with spaces
merge_request: 27087
author:
type: fixed
...@@ -480,29 +480,39 @@ describe WikiPage do ...@@ -480,29 +480,39 @@ describe WikiPage do
let(:untitled_page) { described_class.new(wiki) } let(:untitled_page) { described_class.new(wiki) }
let(:directory_page) do let(:directory_page) do
create_page('parent/child', 'test content') create_page('parent directory/child page', 'test content')
wiki.find_page('parent/child') wiki.find_page('parent directory/child page')
end end
where(:page, :title, :changed) do where(:page, :title, :changed) do
:untitled_page | nil | false :untitled_page | nil | false
:untitled_page | 'new title' | true :untitled_page | 'new title' | true
:new_page | nil | true :new_page | nil | true
:new_page | 'test page' | true :new_page | 'test page' | true
:new_page | 'new title' | true :new_page | 'new title' | true
:existing_page | nil | false :existing_page | nil | false
:existing_page | 'test page' | false :existing_page | 'test page' | false
:existing_page | '/test page' | false :existing_page | 'test-page' | false
:existing_page | 'new title' | true :existing_page | '/test page' | false
:existing_page | '/test-page' | false
:directory_page | nil | false :existing_page | ' test page ' | true
:directory_page | 'parent/child' | false :existing_page | 'new title' | true
:directory_page | 'child' | false :existing_page | 'new-title' | true
:directory_page | '/child' | true
:directory_page | 'parent/other' | true :directory_page | nil | false
:directory_page | 'other/child' | true :directory_page | 'parent directory/child page' | false
:directory_page | 'parent-directory/child page' | false
:directory_page | 'parent-directory/child-page' | false
:directory_page | 'child page' | false
:directory_page | 'child-page' | false
:directory_page | '/child page' | true
:directory_page | 'parent directory/other' | true
:directory_page | 'parent-directory/other' | true
:directory_page | 'parent-directory / child-page' | true
:directory_page | 'other directory/child page' | true
:directory_page | 'other-directory/child page' | true
end end
with_them do with_them do
......
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