have :id in repos controller only match digits
This commit is contained in:
parent
f19bfa1ada
commit
b448410da5
|
@ -3,6 +3,8 @@ require 'travis/api/app'
|
|||
class Travis::Api::App
|
||||
class Endpoint
|
||||
class Repos < Endpoint
|
||||
set :pattern, capture: { id: /\d+/ }
|
||||
|
||||
# Endpoint for getting all repositories.
|
||||
#
|
||||
# You can filter the repositories by adding parameters to the request. For example, you can get all repositories
|
||||
|
@ -18,14 +20,6 @@ class Travis::Api::App
|
|||
end
|
||||
end
|
||||
|
||||
# Retrieves repositories for a given owner.
|
||||
get '/:owner_name' do
|
||||
pass if params[:owner_name] =~ /^\d+$/ # so we don't capture '/:id'
|
||||
prefer_follower do
|
||||
respond_with service(:find_repos, params)
|
||||
end
|
||||
end
|
||||
|
||||
# Gets the repository with the given id.
|
||||
#
|
||||
# ### Response
|
||||
|
@ -37,6 +31,13 @@ class Travis::Api::App
|
|||
end
|
||||
end
|
||||
|
||||
# Retrieves repositories for a given owner.
|
||||
get '/:owner_name' do
|
||||
prefer_follower do
|
||||
respond_with service(:find_repos, params)
|
||||
end
|
||||
end
|
||||
|
||||
get '/:id/cc' do
|
||||
respond_with service(:find_repo, params.merge(schema: 'cc'))
|
||||
end
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Travis::Api::App::Endpoint::Repos do
|
||||
it 'has to be tested'
|
||||
before do
|
||||
described_class.get('/spec/match/:id') { "id" }
|
||||
described_class.get('/spec/match/:name') { "name" }
|
||||
end
|
||||
|
||||
it 'matches id with digits' do
|
||||
get('/repos/spec/match/123').body.should be == "id"
|
||||
end
|
||||
|
||||
it 'does not match id with non-digits' do
|
||||
get('/repos/spec/match/f123').body.should be == "name"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user