diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 431c1e33f55fd8116392d7d2ebeb6fbcebfc5d5a..4d8cfd6368f43dfddc3403dc58c9c3bd22208256 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -47,7 +47,11 @@ class WikiPage # The formatted title of this page. def title - @attributes[:title] || "" + if @attributes[:title] + @attributes[:title].gsub(/-+/, ' ') + else + "" + end end # Sets the title of this page. diff --git a/app/views/projects/wikis/edit.html.haml b/app/views/projects/wikis/edit.html.haml index 49dd7b00ca4fa3f12734c3794f73cbfec9454dcf..5347caf000a4e3e1248edede24a1c6e2211ada6a 100644 --- a/app/views/projects/wikis/edit.html.haml +++ b/app/views/projects/wikis/edit.html.haml @@ -3,7 +3,7 @@ = render 'main_links' %h3.page-title Editing - - %span.light #{@page.title.titleize} + %span.light #{@page.title} %hr = render 'form' diff --git a/app/views/projects/wikis/history.html.haml b/app/views/projects/wikis/history.html.haml index 7001bbd17c199c5a12abdfd15187be4326c0aec1..7bc566cf7f5d23bd467a8dabc2eabd4f2d853bb2 100644 --- a/app/views/projects/wikis/history.html.haml +++ b/app/views/projects/wikis/history.html.haml @@ -1,7 +1,7 @@ = render 'nav' %h3.page-title %span.light History for - = link_to @page.title.titleize, project_wiki_path(@project, @page) + = link_to @page.title, project_wiki_path(@project, @page) %table.table %thead diff --git a/app/views/projects/wikis/pages.html.haml b/app/views/projects/wikis/pages.html.haml index 7a890816568523a35b2258c09a7918e8e995ac11..673e3078be89d303f8fa1e0a1d5acd7f6fb41849 100644 --- a/app/views/projects/wikis/pages.html.haml +++ b/app/views/projects/wikis/pages.html.haml @@ -5,7 +5,7 @@ - @wiki_pages.each do |wiki_page| %li %h4 - = link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page) + = link_to wiki_page.title, project_wiki_path(@project, wiki_page) %small (#{wiki_page.format}) .pull-right %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml index 024ef068d0892a9301b6e32a3a9f65973b9a20b1..cb923e4ca32f00c427f26cdcb70576ae242689cd 100644 --- a/app/views/projects/wikis/show.html.haml +++ b/app/views/projects/wikis/show.html.haml @@ -1,6 +1,6 @@ = render 'nav' %h3.page-title - = @page.title.titleize + = @page.title = render 'main_links' - if @page.historical? .warning_message diff --git a/features/steps/project/wiki.rb b/features/steps/project/wiki.rb index 65e7d094f2d9b1cbf2d16283f82bf834e2b9c0d5..a819ee37d7f7cb012e10e220b9f202cd4f08e40f 100644 --- a/features/steps/project/wiki.rb +++ b/features/steps/project/wiki.rb @@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps Then 'I should see the existing page in the pages list' do page.should have_content current_user.name - page.should have_content @page.title.titleize + page.should have_content @page.title end def wiki diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 2af164bd99b8a17d4a21519235eb6bfb91261f23..005c513af3cd897c500d22be7c01954cfc858473 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -155,4 +155,20 @@ describe WikiPage do end end + describe "#title" do + before do + create_page("Title", "content") + @page = wiki.find_page("Title") + end + + after do + destroy_page("Title") + end + + it "should be replace a hyphen to a space" do + @page.title = "Import-existing-repositories-into-GitLab" + @page.title.should == "Import existing repositories into GitLab" + end + end + end