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

Change WikiPage#directory

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