allow every char in the routes for a wiki

pull/4195/head
Jens Ulferts 9 years ago committed by Oliver Günther
parent b05ac7b06c
commit f2ee664bfb
  1. 7
      config/routes.rb
  2. 30
      spec/routing/wiki_routing_spec.rb

@ -253,7 +253,12 @@ OpenProject::Application.routes.draw do
end
resources :time_entries, controller: 'timelog'
resources :wiki, except: [:index, :new, :create] do
# Match everything to be the ID of the wiki page except the part that
# is reserved for the format. This assumes that we have only two formats:
# .txt and .html
resources :wiki,
constraints: { id: /([^\/]+(?=\.txt|\.html)|[^\/]+)/ },
except: [:index, :create] do
collection do
get :export
get :date_index

@ -30,6 +30,36 @@ require 'spec_helper'
describe WikiController, type: :routing do
describe 'routing' do
it 'should connect GET /projects/:project_id/wiki/:name (without format) to wiki/show' do
expect(get('/projects/abc/wiki/blubs')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs')
end
it 'should connect GET /projects/:project_id/wiki/:name (with a dot in it) to wiki/show' do
expect(get('/projects/abc/wiki/blubs.blubs')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs.blubs')
end
it 'should connect GET /projects/:project_id/wiki/:name.txt to wiki/show' do
expect(get('/projects/abc/wiki/blubs.txt')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs',
format: 'txt')
end
it 'should connect GET /projects/:project_id/wiki/:name.html to wiki/show' do
expect(get('/projects/abc/wiki/blubs.html')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs',
format: 'html')
end
it 'should connect GET /projects/:project_id/wiki/new to wiki/new' do
expect(get('/projects/abc/wiki/new')).to route_to(controller: 'wiki',
action: 'new',

Loading…
Cancel
Save