Change WikiPage#directory to always start a directory hierarchy with '/'
This commit is contained in:
parent
904aa039e5
commit
5607bb8f09
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue