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