diff --git a/CHANGELOG b/CHANGELOG index d176ee3fa6f..441bdc7f4af 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 bug where Wiki pages that included a '/' were no longer accessible (Stan Hu) - Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu) - Add ability to configure Reply-To address in gitlab.yml (Stan Hu) - Fix broken side-by-side diff view on merge request page (Stan Hu) diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 643167947b9..aeb7f0699f5 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -5,6 +5,7 @@ class Projects::WikisController < Projects::ApplicationController before_filter :authorize_write_wiki!, only: [:edit, :create, :history] before_filter :authorize_admin_wiki!, only: :destroy before_filter :load_project_wiki + include WikiHelper def pages @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(PER_PAGE) @@ -45,7 +46,10 @@ class Projects::WikisController < Projects::ApplicationController return render('empty') unless can?(current_user, :write_wiki, @project) if @page.update(content, format, message) - redirect_to [@project.namespace.becomes(Namespace), @project, @page], notice: 'Wiki was successfully updated.' + redirect_to( + namespace_project_wiki_path(@project.namespace, @project, @page), + notice: 'Wiki was successfully updated.' + ) else render 'edit' end diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb new file mode 100644 index 00000000000..a3bc64c010e --- /dev/null +++ b/app/helpers/wiki_helper.rb @@ -0,0 +1,22 @@ +module WikiHelper + # Rails v4.1.9+ escapes all model IDs, converting slashes into %2F. The + # only way around this is to implement our own path generators. + def namespace_project_wiki_path(namespace, project, wiki_page, *args) + slug = + case wiki_page + when Symbol + wiki_page + else + wiki_page.slug + end + namespace_project_path(namespace, project) + "/wikis/#{slug}" + end + + def edit_namespace_project_wiki_path(namespace, project, wiki_page, *args) + namespace_project_wiki_path(namespace, project, wiki_page) + '/edit' + end + + def history_namespace_project_wiki_path(namespace, project, wiki_page, *args) + namespace_project_wiki_path(namespace, project, wiki_page) + '/history' + end +end diff --git a/features/project/wiki.feature b/features/project/wiki.feature index 4a8c771ddac..977cd609a11 100644 --- a/features/project/wiki.feature +++ b/features/project/wiki.feature @@ -62,3 +62,27 @@ Feature: Project Wiki And I browse to wiki page with images And I click on image link Then I should see the new wiki page form + + @javascript + Scenario: New Wiki page that has a path + Given I create a New page with paths + And I click on the "Pages" button + Then I should see non-escaped link in the pages list + + @javascript + Scenario: Edit Wiki page that has a path + Given I create a New page with paths + And I click on the "Pages" button + And I edit the Wiki page with a path + Then I should see a non-escaped path + And I should see the Editing page + And I change the content + Then I should see the updated content + + @javascript + Scenario: View the page history of a Wiki page that has a path + Given I create a New page with paths + And I click on the "Pages" button + And I view the page history of a Wiki page that has a path + Then I should see a non-escaped path + And I should see the page history diff --git a/features/steps/project/wiki.rb b/features/steps/project/wiki.rb index cd7d5eac243..bb93e582a1f 100644 --- a/features/steps/project/wiki.rb +++ b/features/steps/project/wiki.rb @@ -3,6 +3,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps include SharedProject include SharedNote include SharedPaths + include WikiHelper step 'I click on the Cancel button' do within(:css, ".form-actions") do @@ -123,6 +124,41 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps page.should have_content('Editing - image.jpg') end + step 'I create a New page with paths' do + click_on 'New Page' + fill_in 'Page slug', with: 'one/two/three' + click_on 'Build' + fill_in "wiki_content", with: 'wiki content' + click_on "Create page" + current_path.should include 'one/two/three' + end + + step 'I should see non-escaped link in the pages list' do + page.should have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three']") + end + + step 'I edit the Wiki page with a path' do + click_on 'three' + click_on 'Edit' + end + + step 'I should see a non-escaped path' do + current_path.should include 'one/two/three' + end + + step 'I should see the Editing page' do + page.should have_content('Editing') + end + + step 'I view the page history of a Wiki page that has a path' do + click_on 'three' + click_on 'Page History' + end + + step 'I should see the page history' do + page.should have_content('History for') + end + def wiki @project_wiki = ProjectWiki.new(project, current_user) end