v3: add /build/:id endpoint
This commit is contained in:
parent
c2f087ea8d
commit
7fce1b93f3
|
@ -20,6 +20,10 @@ module Travis::API::V3
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def build_visible?(build)
|
||||||
|
visible? build.repository
|
||||||
|
end
|
||||||
|
|
||||||
def organization_visible?(organization)
|
def organization_visible?(organization)
|
||||||
unrestricted_api?
|
unrestricted_api?
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Travis::API::V3
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
return key unless key.is_a? Symbol
|
return key unless key.is_a? Symbol
|
||||||
resolver_cache[key] ||= const_get(key.to_s.camelize)
|
resolver_cache[key] ||= const_get(key.to_s.camelize, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def extended(base)
|
def extended(base)
|
||||||
|
|
|
@ -25,6 +25,7 @@ module Travis::API::V3
|
||||||
return nil unless model.last_build_id
|
return nil unless model.last_build_id
|
||||||
{
|
{
|
||||||
:@type => 'build'.freeze,
|
:@type => 'build'.freeze,
|
||||||
|
:@href => Renderer.href(:build, script_name: script_name, id: model.last_build_id),
|
||||||
:id => model.last_build_id,
|
:id => model.last_build_id,
|
||||||
:number => model.last_build_number,
|
:number => model.last_build_number,
|
||||||
:state => model.last_build_state.to_s,
|
:state => model.last_build_state.to_s,
|
||||||
|
|
|
@ -19,6 +19,11 @@ module Travis::API::V3
|
||||||
get :for_current_user
|
get :for_current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resource :build do
|
||||||
|
route '/build/{build.id}'
|
||||||
|
get :find
|
||||||
|
end
|
||||||
|
|
||||||
resource :organization do
|
resource :organization do
|
||||||
route '/org/{organization.id}'
|
route '/org/{organization.id}'
|
||||||
get :find
|
get :find
|
||||||
|
|
|
@ -2,6 +2,7 @@ module Travis::API::V3
|
||||||
module Services
|
module Services
|
||||||
extend ConstantResolver
|
extend ConstantResolver
|
||||||
|
|
||||||
|
Build = Module.new { extend Services }
|
||||||
Organization = Module.new { extend Services }
|
Organization = Module.new { extend Services }
|
||||||
Organizations = Module.new { extend Services }
|
Organizations = Module.new { extend Services }
|
||||||
Repositories = Module.new { extend Services }
|
Repositories = Module.new { extend Services }
|
||||||
|
|
|
@ -12,6 +12,8 @@ describe Travis::API::V3::ServiceIndex do
|
||||||
"find" => [{"request-method"=>"GET", "uri-template"=>"#{path}repo/{repository.id}"}] },
|
"find" => [{"request-method"=>"GET", "uri-template"=>"#{path}repo/{repository.id}"}] },
|
||||||
"repositories" => {
|
"repositories" => {
|
||||||
"for_current_user" => [{"request-method"=>"GET", "uri-template"=>"#{path}repos"}] },
|
"for_current_user" => [{"request-method"=>"GET", "uri-template"=>"#{path}repos"}] },
|
||||||
|
"build" => {
|
||||||
|
"find" => [{"request-method"=>"GET", "uri-template"=>"#{path}build/{build.id}"}] },
|
||||||
"organizations" => {
|
"organizations" => {
|
||||||
"for_current_user" => [{"request-method"=>"GET", "uri-template"=>"#{path}orgs"}] },
|
"for_current_user" => [{"request-method"=>"GET", "uri-template"=>"#{path}orgs"}] },
|
||||||
"organization" => {
|
"organization" => {
|
||||||
|
|
|
@ -32,6 +32,7 @@ describe Travis::API::V3::Services::Repositories::ForCurrentUser do
|
||||||
"login" => "svenfuchs" },
|
"login" => "svenfuchs" },
|
||||||
"last_build" => {
|
"last_build" => {
|
||||||
"@type" => "build",
|
"@type" => "build",
|
||||||
|
"@href" => "/v3/build/#{repo.last_build_id}",
|
||||||
"id" => repo.last_build_id,
|
"id" => repo.last_build_id,
|
||||||
"number" => "2",
|
"number" => "2",
|
||||||
"state" => "passed",
|
"state" => "passed",
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe Travis::API::V3::Services::Repository::Find do
|
||||||
"login" => "svenfuchs" },
|
"login" => "svenfuchs" },
|
||||||
"last_build" => {
|
"last_build" => {
|
||||||
"@type" => "build",
|
"@type" => "build",
|
||||||
|
"@href" => "/v3/build/#{repo.last_build_id}",
|
||||||
"id" => repo.last_build_id,
|
"id" => repo.last_build_id,
|
||||||
"number" => "2",
|
"number" => "2",
|
||||||
"state" => "passed",
|
"state" => "passed",
|
||||||
|
@ -94,6 +95,7 @@ describe Travis::API::V3::Services::Repository::Find do
|
||||||
"login" => "svenfuchs" },
|
"login" => "svenfuchs" },
|
||||||
"last_build" => {
|
"last_build" => {
|
||||||
"@type" => "build",
|
"@type" => "build",
|
||||||
|
"@href" => "/v3/build/#{repo.last_build_id}",
|
||||||
"id" => repo.last_build_id,
|
"id" => repo.last_build_id,
|
||||||
"number" => "2",
|
"number" => "2",
|
||||||
"state" => "passed",
|
"state" => "passed",
|
||||||
|
@ -150,6 +152,7 @@ describe Travis::API::V3::Services::Repository::Find do
|
||||||
"login" => "svenfuchs" },
|
"login" => "svenfuchs" },
|
||||||
"last_build" => {
|
"last_build" => {
|
||||||
"@type" => "build",
|
"@type" => "build",
|
||||||
|
"@href" => "/v3/build/#{repo.last_build_id}",
|
||||||
"id" => repo.last_build_id,
|
"id" => repo.last_build_id,
|
||||||
"number" => "2",
|
"number" => "2",
|
||||||
"state" => "passed",
|
"state" => "passed",
|
||||||
|
@ -212,6 +215,7 @@ describe Travis::API::V3::Services::Repository::Find do
|
||||||
"login" => "svenfuchs" },
|
"login" => "svenfuchs" },
|
||||||
"last_build" => {
|
"last_build" => {
|
||||||
"@type" => "build",
|
"@type" => "build",
|
||||||
|
"@href" => "/v3/build/#{repo.last_build_id}",
|
||||||
"id" => repo.last_build_id,
|
"id" => repo.last_build_id,
|
||||||
"number" => "2",
|
"number" => "2",
|
||||||
"state" => "passed",
|
"state" => "passed",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user