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

Add WikiPage.unhyphenize

parent 4c57fa42
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7,7 +7,7 @@ module WikiHelper
# capitalized name of the page itself.
def breadcrumb(page_slug)
page_slug.split('/').
map { |dir_or_page| dir_or_page.gsub(/-+/, ' ').capitalize }.
map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }.
join(' / ')
end
end
Loading
Loading
@@ -34,6 +34,10 @@ class WikiPage
flatten
end
 
def self.unhyphenize(name)
name.gsub(/-+/, ' ')
end
def to_key
[:slug]
end
Loading
Loading
@@ -78,7 +82,7 @@ class WikiPage
# The formatted title of this page.
def title
if @attributes[:title]
@attributes[:title].gsub(/-+/, ' ')
self.class.unhyphenize(@attributes[:title])
else
""
end
Loading
Loading
Loading
Loading
@@ -68,6 +68,14 @@ describe WikiPage, models: true do
end
end
 
describe '.unhyphenize' do
it 'removes hyphens from a name' do
name = 'a-name--with-hyphens'
expect(WikiPage.unhyphenize(name)).to eq('a name with hyphens')
end
end
describe "#initialize" do
context "when initialized with an existing gollum page" do
before do
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