Implement a few missing endpoints

This commit is contained in:
Piotr Sarnacki 2012-08-10 13:41:06 +02:00
parent 44afb75630
commit 159a8e105b
7 changed files with 29 additions and 10 deletions

View File

@ -5,7 +5,7 @@ class Travis::Api::App
# TODO: Add documentation.
class Artifacts < Endpoint
# TODO: Add documentation.
get('/:id') { |id| Artifact.find(id) }
get('/:id') { |id| body Artifact.find(id) }
end
end
end

View File

@ -4,8 +4,17 @@ class Travis::Api::App
class Endpoint
# TODO: Add documentation.
class Branches < Endpoint
# TODO: Add better implementation and documentation.
get('/') {{ branches: [] }}
# TODO: Add documentation.
get('/') do
body repository, :type => "Branches"
end
private
def repository
pass if params.empty?
Repository.find_by(params) || not_found
end
end
end
end

View File

@ -14,7 +14,7 @@ class Travis::Api::App
# TODO: Add documentation.
get '/:id' do
one = params[:repository_id] ? repository.builds : Build
one.includes(:commit, :matrix => [:commit, :log]).find(params[:id])
body one.includes(:commit, :matrix => [:commit, :log]).find(params[:id])
end
private

View File

@ -5,10 +5,20 @@ class Travis::Api::App
# TODO: Add documentation.
class Jobs < Endpoint
# TODO: Add implementation and documentation.
get('/') { raise NotImplementedError }
get('/') do
if params[:ids]
Job.where(:id => params[:ids]).includes(:commit, :log)
else
jobs = Job.queued.includes(:commit, :log)
jobs = jobs.where(:queue => params[:queue]) if params[:queue]
jobs
end
end
# TODO: Add implementation and documentation.
get('/:id') { raise NotImplementedError }
get('/:id') do
body Job.find(params[:id])
end
end
end
end

View File

@ -14,7 +14,7 @@ class Travis::Api::App
end
# TODO: Add documentation.
get('/:id') { Repository.find_by(params) }
get('/:id') { body Repository.find_by(params) }
end
end
end

View File

@ -10,8 +10,8 @@ class Travis::Api::App
halt render_json(resource, options)
end
def body(value = nil, &block)
value = render_json(value) if value
def body(value = nil, options = {}, &block)
value = render_json(value, options) if value
super(value, &block)
end

View File

@ -1,5 +1,5 @@
require 'spec_helper'
describe Travis::Api::App::Endpoint::Branches do
it 'has to be implemented'
it 'has to be tested'
end