Allow branch names to contain slashes

Fixes: #145
This commit is contained in:
C. Scott Ananian 2014-11-12 16:40:20 -05:00
parent e45aa12d97
commit 7ba84757dc
2 changed files with 13 additions and 4 deletions

View File

@ -97,8 +97,9 @@ class Travis::Api::App
respond_with service(:find_branches, params), type: :branches, version: :v2
end
# Gets lastest build on a branch branches
get '/:repository_id/branches/:branch' do
# Gets latest build on a branch
get '/:repository_id/branches/*' do
params[:branch] = params[:splat]
respond_with service(:find_branch, params), type: :branch, version: :v2
end
@ -169,8 +170,9 @@ class Travis::Api::App
respond_with service(:find_branches, params), type: :branches, version: :v2
end
# Gets lastest build on a branch branches
get '/:owner_name/:name/branches/:branch' do
# Gets latest build on a branch
get '/:owner_name/:name/branches/*' do
params[:branch] = params[:splat]
respond_with service(:find_branch, params), type: :branch, version: :v2
end

View File

@ -151,6 +151,13 @@ describe 'Repos' do
body['branch']['id'].should == mybuild.id
end
it 'GET /repos/svenfuchs/minimal/branches/my/branch' do
mybuild = Factory(:build, repository: repo, state: :started, commit: Factory(:commit, branch: 'my/branch'), request: Factory(:request, event_type: 'push'))
response = get "/repos/svenfuchs/minimal/branches/my/branch", {}, headers
body = JSON.parse(response.body)
body['branch']['id'].should == mybuild.id
end
describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do
let(:on_foo) { Factory(:commit, branch: 'foo') }
let(:on_bar) { Factory(:commit, branch: 'bar') }