Merge pull request #146 from cscott/bug-145

Allow branch names to contain slashes.
This commit is contained in:
Konstantin Haase 2015-02-23 12:51:17 +01:00
commit 20e9448dc1
2 changed files with 30 additions and 4 deletions

View File

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

View File

@ -134,6 +134,30 @@ describe 'Repos' do
JSON.parse(result.body).should == { 'file' => 'not found' } JSON.parse(result.body).should == { 'file' => 'not found' }
end end
it 'GET /repos/svenfuchs/minimal/branches' do
response = get '/repos/svenfuchs/minimal/branches', {}, headers
response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v2', type: 'branches')
end
it 'GET /repos/1/branches' do
response = get "/repos/#{repo.id}/branches", {}, headers
response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v2', type: 'branches')
end
it 'GET /repos/svenfuchs/minimal/branches/mybranch' do
mybuild = Factory(:build, repository: repo, state: :started, commit: Factory(:commit, branch: 'mybranch'), request: Factory(:request, event_type: 'push'))
response = get "/repos/svenfuchs/minimal/branches/mybranch", {}, headers
body = JSON.parse(response.body)
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 describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do
let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_foo) { Factory(:commit, branch: 'foo') }
let(:on_bar) { Factory(:commit, branch: 'bar') } let(:on_bar) { Factory(:commit, branch: 'bar') }