Commit d2b3fe45 authored by Alex Braha Stoll's avatar Alex Braha Stoll

Change WikiPage#directory

parent 104bfa2a
......@@ -25,10 +25,10 @@ class WikiPage
pages.sort_by { |page| [page.directory, page.slug] }.
group_by { |page| page.directory }.
map do |dir, pages|
if dir == '/'
pages
else
if dir.present?
WikiDirectory.new(dir, pages)
else
pages
end
end.
flatten
......@@ -98,8 +98,7 @@ class WikiPage
# The hierarchy of the directory this page is contained in.
def directory
dir = wiki.page_title_and_dir(slug).last
"/#{dir}"
wiki.page_title_and_dir(slug).last
end
# The processed/formatted content of this page.
......
......@@ -252,11 +252,11 @@ describe WikiPage, models: true do
describe '#directory' do
context 'when the page is at the root directory' do
it 'returns /' do
it 'returns an empty string' do
create_page('file', 'content')
page = wiki.find_page('file')
expect(page.directory).to eq('/')
expect(page.directory).to eq('')
end
end
......@@ -265,7 +265,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