Commit 352bb972665822cace72497241e7b309c2167268
Exists in
spb-stable
and in
3 other branches
Merge pull request #6731 from hiroponz/better-title-format-for-wiki-page
Better title format for wiki page
Showing
7 changed files
with
26 additions
and
6 deletions
Show diff stats
app/models/wiki_page.rb
| @@ -47,7 +47,11 @@ class WikiPage | @@ -47,7 +47,11 @@ class WikiPage | ||
| 47 | 47 | ||
| 48 | # The formatted title of this page. | 48 | # The formatted title of this page. |
| 49 | def title | 49 | def title |
| 50 | - @attributes[:title] || "" | 50 | + if @attributes[:title] |
| 51 | + @attributes[:title].gsub(/-+/, ' ') | ||
| 52 | + else | ||
| 53 | + "" | ||
| 54 | + end | ||
| 51 | end | 55 | end |
| 52 | 56 | ||
| 53 | # Sets the title of this page. | 57 | # Sets the title of this page. |
app/views/projects/wikis/edit.html.haml
app/views/projects/wikis/history.html.haml
| 1 | = render 'nav' | 1 | = render 'nav' |
| 2 | %h3.page-title | 2 | %h3.page-title |
| 3 | %span.light History for | 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 | %table.table | 6 | %table.table |
| 7 | %thead | 7 | %thead |
app/views/projects/wikis/pages.html.haml
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | - @wiki_pages.each do |wiki_page| | 5 | - @wiki_pages.each do |wiki_page| |
| 6 | %li | 6 | %li |
| 7 | %h4 | 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 | %small (#{wiki_page.format}) | 9 | %small (#{wiki_page.format}) |
| 10 | .pull-right | 10 | .pull-right |
| 11 | %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} | 11 | %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} |
app/views/projects/wikis/show.html.haml
features/steps/project/wiki.rb
| @@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps | @@ -83,7 +83,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps | ||
| 83 | 83 | ||
| 84 | Then 'I should see the existing page in the pages list' do | 84 | Then 'I should see the existing page in the pages list' do |
| 85 | page.should have_content current_user.name | 85 | page.should have_content current_user.name |
| 86 | - page.should have_content @page.title.titleize | 86 | + page.should have_content @page.title |
| 87 | end | 87 | end |
| 88 | 88 | ||
| 89 | def wiki | 89 | def wiki |
spec/models/wiki_page_spec.rb
| @@ -155,4 +155,20 @@ describe WikiPage do | @@ -155,4 +155,20 @@ describe WikiPage do | ||
| 155 | end | 155 | end |
| 156 | end | 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 | end | 174 | end |