diff options
author | Alex Braha Stoll <alexbrahastoll@gmail.com> | 2016-12-19 02:22:20 +0300 |
---|---|---|
committer | Alex Braha Stoll <alexbrahastoll@gmail.com> | 2016-12-31 21:55:50 +0300 |
commit | 5bbe6559917e1e64cdb047b6235715e2a7f002f2 (patch) | |
tree | 8ec5db6fa9527808826904aa5d32016a645e2b8d /spec | |
parent | 294acf1c5cd2aea353081059c60b3951a2cf7c77 (diff) |
Add component to show the full path of a wiki page when viewing its content
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/wiki_page_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 595d4a621c1..c40a89b9dfb 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -224,6 +224,46 @@ describe WikiPage, models: true do end end + describe '#directory' do + context 'when the page is at the root directory' do + it 'returns /' do + create_page('file', 'content') + page = wiki.find_page('file') + + expect(page.directory).to eq('/') + end + end + + context 'when the page is inside an actual directory' do + it 'returns the full directory hierarchy' 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') + end + end + end + + describe '#full_path' do + context 'when the page is at the root directory' do + it 'returns /filename.fileextension' do + create_page('file', 'content') + page = wiki.find_page('file') + + expect(page.full_path).to eq('/file.md') + end + end + + context 'when the page is inside an actual directory' do + it 'returns /directory/filename.fileextension' do + create_page('dir/file', 'content') + page = wiki.find_page('dir/file') + + expect(page.full_path).to eq('/dir/file.md') + end + end + end + describe '#historical?' do before do create_page('Update', 'content') |