Commit 5607bb8f authored by Alex Braha Stoll's avatar Alex Braha Stoll

Change WikiPage#directory to always start a directory hierarchy with '/'

parent 904aa039
......@@ -89,7 +89,7 @@ class WikiPage
# The hierarchy of the directory this page is contained in.
def directory
dir = wiki.page_title_and_dir(slug).last
dir.present? ? dir : '/'
"/#{dir}"
end
# The processed/formatted content of this page.
......@@ -106,7 +106,7 @@ class WikiPage
# The full path for this page, including its filename and extension.
def full_path
"/#{directory}/#{page.filename}".gsub(/\/+/, '/')
"#{directory}/#{page.filename}".gsub(/\/+/, '/')
end
# The commit message for this page version.
......
......@@ -27,7 +27,7 @@ describe WikiPage, models: true do
page_2 = wiki.find_page('dir_1/page_2')
page_3 = wiki.find_page('dir_1/dir_2/page_3')
expected_grouped_pages = {
'/' => [page_1], 'dir_1' => [page_2], 'dir_1/dir_2' => [page_3]
'/' => [page_1], '/dir_1' => [page_2], '/dir_1/dir_2' => [page_3]
}
grouped_pages = WikiPage.group_by_directory(wiki.pages)
......@@ -239,7 +239,7 @@ describe WikiPage, models: true do
create_page('dir_1/dir_1_1/file', 'content')
page = wiki.find_page('dir_1/dir_1_1/file')
expect(page.directory).to eq('dir_1/dir_1_1')
expect(page.directory).to eq('/dir_1/dir_1_1')
end
end
end
......
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