Skip to content
Snippets Groups Projects
Commit 5607bb8f authored by Alex Braha Stoll's avatar Alex Braha Stoll
Browse files

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

parent 904aa039
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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.
Loading
Loading
@@ -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.
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment