Commit bca528a57c9276c0cd815d67fed4a72c514d53a2

Authored by Hiroyuki Sato
1 parent 03472b4f

Better title format for wiki page

The title format for wiki page may be unintelligible.
For example 'GitLab' is converted to 'Git Lab', 'MySQL' is converted to
'My Sql', etc.
app/models/wiki_page.rb
... ... @@ -47,7 +47,11 @@ class WikiPage
47 47  
48 48 # The formatted title of this page.
49 49 def title
50   - @attributes[:title] || ""
  50 + if @attributes[:title]
  51 + @attributes[:title].gsub(/-+/, ' ')
  52 + else
  53 + ""
  54 + end
51 55 end
52 56  
53 57 # Sets the title of this page.
... ...
app/views/projects/wikis/edit.html.haml
... ... @@ -3,7 +3,7 @@
3 3 = render 'main_links'
4 4 %h3.page-title
5 5 Editing -
6   - %span.light #{@page.title.titleize}
  6 + %span.light #{@page.title}
7 7 %hr
8 8 = render 'form'
9 9  
... ...
app/views/projects/wikis/history.html.haml
1 1 = render 'nav'
2 2 %h3.page-title
3 3 %span.light History for
4   - = link_to @page.title.titleize, project_wiki_path(@project, @page)
  4 + = link_to @page.title, project_wiki_path(@project, @page)
5 5  
6 6 %table.table
7 7 %thead
... ...
app/views/projects/wikis/pages.html.haml
... ... @@ -5,7 +5,7 @@
5 5 - @wiki_pages.each do |wiki_page|
6 6 %li
7 7 %h4
8   - = link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page)
  8 + = link_to wiki_page.title, project_wiki_path(@project, wiki_page)
9 9 %small (#{wiki_page.format})
10 10 .pull-right
11 11 %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)}
... ...
app/views/projects/wikis/show.html.haml
1 1 = render 'nav'
2 2 %h3.page-title
3   - = @page.title.titleize
  3 + = @page.title
4 4 = render 'main_links'
5 5 - if @page.historical?
6 6 .warning_message
... ...
features/steps/project/wiki.rb
... ... @@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
83 83  
84 84 Then 'I should see the existing page in the pages list' do
85 85 page.should have_content current_user.name
86   - page.should have_content @page.title.titleize
  86 + page.should have_content @page.title
87 87 end
88 88  
89 89 def wiki
... ...
spec/models/wiki_page_spec.rb
... ... @@ -155,4 +155,20 @@ describe WikiPage do
155 155 end
156 156 end
157 157  
  158 + describe "#title" do
  159 + before do
  160 + create_page("Title", "content")
  161 + @page = wiki.find_page("Title")
  162 + end
  163 +
  164 + after do
  165 + destroy_page("Title")
  166 + end
  167 +
  168 + it "should be replace a hyphen to a space" do
  169 + @page.title = "Import-existing-repositories-into-GitLab"
  170 + @page.title.should == "Import existing repositories into GitLab"
  171 + end
  172 + end
  173 +
158 174 end
... ...