diff --git a/CHANGELOG b/CHANGELOG index 6e40fa9aef839dac8d3e68127de015d1684769a3..7b22c6b36f23b5e14217306dd39fe1fcbdaab772 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.10.0 (unreleased) + - Fix dots in Wiki slugs causing errors (Stan Hu) - Update poltergeist to version 1.6.0 to support PhantomJS 2.0 (Zeger-Jan van de Weg) - Fix cross references when usernames, milestones, or project names contain underscores (Stan Hu) - enable line wrapping per default and remove the checkbox to toggle it (Hannes Rosenögger) diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 55438bee245ee9648c2e97596c38ab2fb0158044..772c868d9cd0088307f7bab85d8166878a528a1c 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -104,7 +104,7 @@ class ProjectWiki def page_title_and_dir(title) title_array = title.split("/") title = title_array.pop - [title.gsub(/\.[^.]*$/, ""), title_array.join("/")] + [title, title_array.join("/")] end def search_files(query) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 32981a0e664be3a917c8ae7eecdb7b546e673723..e9413c34baed37f1e8008f5c7c8f14f8f8f1c5d7 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -179,7 +179,8 @@ class WikiPage if valid? && project_wiki.send(method, *args) page_details = if method == :update_page - @page.path + # Use url_path instead of path to omit format extension + @page.url_path else title end diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index f3fd805783f14f5606681edb5e479fb7bc3f9ea2..fceb7668cac4cf22dcb1b73d97b021ba2137057c 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -78,6 +78,47 @@ describe WikiPage do end end + describe "dot in the title" do + let(:title) { 'Index v1.2.3' } + + before do + @wiki_attr = {title: title, content: "Home Page", format: "markdown"} + end + + describe "#create" do + after do + destroy_page(title) + end + + context "with valid attributes" do + it "saves the wiki page" do + subject.create(@wiki_attr) + expect(wiki.find_page(title)).not_to be_nil + end + + it "returns true" do + expect(subject.create(@wiki_attr)).to eq(true) + end + end + end + + describe "#update" do + before do + create_page(title, "content") + @page = wiki.find_page(title) + end + + it "updates the content of the page" do + @page.update("new content") + @page = wiki.find_page(title) + end + + it "returns true" do + expect(@page.update("more content")).to be_truthy + end + end + end + describe "#update" do before do create_page("Update", "content")