Fix 404 when group path has dot in the name

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-10-16 12:49:23 +03:00
parent 59fd455577
commit c48f715318
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
2 changed files with 10 additions and 1 deletions

View file

@ -1,7 +1,10 @@
require 'constraints/group_url_constrainer'
constraints(GroupUrlConstrainer.new) do
scope(path: ':id', as: :group, controller: :groups) do
scope(path: ':id',
as: :group,
constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ },
controller: :groups) do
get '/', action: :show
patch '/', action: :update
put '/', action: :update

View file

@ -270,6 +270,12 @@ describe "Groups", "routing" do
expect(get('/1')).to route_to('groups#show', id: '1')
end
it "also display group#show with dot in the path" do
allow(Group).to receive(:find_by_path).and_return(true)
expect(get('/group.with.dot')).to route_to('groups#show', id: 'group.with.dot')
end
end
describe HealthCheckController, 'routing' do