Merge branch 'cd-v3-parity'

This commit is contained in:
Konstantin Haase 2015-08-25 17:34:53 +02:00
commit d207f1c31c
14 changed files with 237 additions and 178 deletions

View File

@ -68,12 +68,13 @@ module Travis::API::V3
return { :@href => href } return { :@href => href }
end end
result = {} result = {}
result[:@type] = self.class.type if self.class.type result[:@type] = self.class.type if self.class.type
result[:@href] = href if href result[:@href] = href if href
fields = self.class.representations.fetch(representation) result[:@representation] = representation
nested_included = included + [model] fields = self.class.representations.fetch(representation)
modes = {} nested_included = included + [model]
modes = {}
if permissions = access_control.permissions(model) and (representation != :minimal or include? :@permissions) if permissions = access_control.permissions(model) and (representation != :minimal or include? :@permissions)
result[:@permissions] = permissions.to_h result[:@permissions] = permissions.to_h
@ -96,7 +97,7 @@ module Travis::API::V3
raise WrongParams, 'no field %p to include'.freeze % qualified_field unless result.keys.any? { |k| k.to_s == field.to_s } raise WrongParams, 'no field %p to include'.freeze % qualified_field unless result.keys.any? { |k| k.to_s == field.to_s }
end end
end end
fields.each do |field| fields.each do |field|
value = Renderer.render_value(send(field), value = Renderer.render_value(send(field),
access_control: access_control, access_control: access_control,

View File

@ -85,7 +85,6 @@ module Travis::API::V3
end end
def paginate(result) def paginate(result)
p params
self.class.paginator.paginate(result, self.class.paginator.paginate(result,
limit: params['limit'.freeze], limit: params['limit'.freeze],
offset: params['offset'.freeze], offset: params['offset'.freeze],

View File

@ -18,30 +18,34 @@ describe Travis::API::V3::Services::Accounts::ForCurrentUser do
before { get("/v3/accounts", {}, headers) } before { get("/v3/accounts", {}, headers) }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "accounts", "@type" => "accounts",
"@href" => "/v3/accounts", "@href" => "/v3/accounts",
"accounts" => [{ "accounts" => [{
"@type" => "account", "@type" => "account",
"@permissions" => { "read"=>true }, "@representation" =>"standard",
"id" => repo.owner.github_id, "@permissions" => { "read"=>true },
"subscribed" => false, "id" => repo.owner.github_id,
"educational" => false, "subscribed" => false,
"owner" => { "educational" => false,
"@type" => "user", "owner" => {
"@href" => "/v3/user/#{repo.owner_id}", "@type" => "user",
"id" => repo.owner_id, "@href" => "/v3/user/#{repo.owner_id}",
"login" => "svenfuchs" }}, "@representation" =>"minimal",
{"@type" => "account", "id" => repo.owner_id,
"@permissions" => { "read"=>true }, "login" => "svenfuchs" }},
"id" => 42, {"@type" => "account",
"subscribed" => false, "@representation" => "standard",
"educational" => false, "@permissions" => { "read"=>true },
"owner" => { "id" => 42,
"@type" => "organization", "subscribed" => false,
"@href" => "/v3/org/#{org.id}", "educational" => false,
"id" => org.id, "owner" => {
"login" => "example-org"} "@type" => "organization",
"@href" => "/v3/org/#{org.id}",
"@representation" => "minimal",
"id" => org.id,
"login" => "example-org"}
}] }]
}} }}
end end
end end

View File

@ -10,15 +10,18 @@ describe Travis::API::V3::Services::Repository::Find do
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "standard",
"name" => "master", "name" => "master",
"repository" => { "repository" => {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation"=> "minimal",
"id" => repo.id, "id" => repo.id,
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.default_branch.last_build.id}", "@href" => "/v3/build/#{repo.default_branch.last_build.id}",
"@representation"=> "minimal",
"id" => repo.default_branch.last_build.id, "id" => repo.default_branch.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -28,4 +31,4 @@ describe Travis::API::V3::Services::Repository::Find do
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}}} "finished_at" => nil}}}
end end
end end

View File

@ -36,8 +36,8 @@ describe Travis::API::V3::Services::Builds::Find do
"next" => { "next" => {
"@href" => "/v3/repo/#{repo.id}/builds?limit=1&offset=1", "@href" => "/v3/repo/#{repo.id}/builds?limit=1&offset=1",
"offset" => 1, "offset" => 1,
"limit" =>1}, "limit" => 1},
"prev" =>nil, "prev" => nil,
"first" => { "first" => {
"@href" => "/v3/repo/#{repo.id}/builds?limit=1", "@href" => "/v3/repo/#{repo.id}/builds?limit=1",
"offset" => 0, "offset" => 0,
@ -49,6 +49,7 @@ describe Travis::API::V3::Services::Builds::Find do
"builds" => [{ "builds" => [{
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation" => "standard",
"id" => build.id, "id" => build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -60,16 +61,19 @@ describe Travis::API::V3::Services::Builds::Find do
"repository" => { "repository" => {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation"=> "minimal",
"id" => repo.id, "id" => repo.id,
"slug"=>"svenfuchs/minimal" }, "slug" => "svenfuchs/minimal" },
"branch" => { "branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation"=> "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@href"=>"/v3/build/#{build.id}" }}, "@href" => "/v3/build/#{build.id}" }},
"commit" => { "commit" => {
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal",
"id" => 5, "id" => 5,
"sha" => "add057e66c3e1d59ef1f", "sha" => "add057e66c3e1d59ef1f",
"ref" => "refs/heads/master", "ref" => "refs/heads/master",
@ -112,6 +116,7 @@ describe Travis::API::V3::Services::Builds::Find do
"builds" => [{ "builds" => [{
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation" => "standard",
"id" => build.id, "id" => build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -119,20 +124,23 @@ describe Travis::API::V3::Services::Builds::Find do
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" =>nil, "finished_at" => nil,
"repository" => { "repository" => {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation"=> "minimal",
"id" => repo.id, "id" => repo.id,
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"branch" => { "branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation"=> "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@href" => "/v3/build/#{build.id}"}}, "@href" => "/v3/build/#{build.id}"}},
"commit" => { "commit" => {
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal",
"id" => 5, "id" => 5,
"sha" => "add057e66c3e1d59ef1f", "sha" => "add057e66c3e1d59ef1f",
"ref" => "refs/heads/master", "ref" => "refs/heads/master",

View File

@ -9,14 +9,15 @@ describe Travis::API::V3::Services::Organization::Find do
before { get("/v3/org/#{org.id}") } before { get("/v3/org/#{org.id}") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@permissions" => { "read"=>true, "sync"=>false }, "@representation" => "standard",
"id" => org.id, "@permissions" => { "read"=>true, "sync"=>false },
"login" => "example-org", "id" => org.id,
"name" => nil, "login" => "example-org",
"github_id" => nil, "name" => nil,
"avatar_url" => nil "github_id" => nil,
"avatar_url" => nil
}} }}
end end

View File

@ -18,18 +18,19 @@ describe Travis::API::V3::Services::Organizations::ForCurrentUser do
before { get("/v3/orgs", {}, headers) } before { get("/v3/orgs", {}, headers) }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organizations", "@type" => "organizations",
"@href" => "/v3/orgs", "@href" => "/v3/orgs",
"organizations" => [{ "organizations" => [{
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@permissions" => { "read"=>true, "sync"=>true }, "@representation" => "standard",
"id" => org.id, "@permissions" => { "read"=>true, "sync"=>true },
"login" => "example-org", "id" => org.id,
"name" => nil, "login" => "example-org",
"github_id" => nil, "name" => nil,
"avatar_url" => nil "github_id" => nil,
"avatar_url" => nil
}] }]
}} }}
end end
end end

View File

@ -10,14 +10,15 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-org") } before { get("/v3/owner/example-org") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@permissions" => { "read"=>true, "sync"=>false }, "@representation" => "standard",
"id" => org.id, "@permissions" => { "read"=>true, "sync"=>false },
"login" => "example-org", "id" => org.id,
"name" => nil, "login" => "example-org",
"github_id" => nil, "name" => nil,
"avatar_url" => nil "github_id" => nil,
"avatar_url" => nil
}} }}
end end
@ -30,36 +31,39 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-org?include=organization.repositories,user.repositories") } before { get("/v3/owner/example-org?include=organization.repositories,user.repositories") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@permissions" => { "read"=>true, "sync"=>false }, "@representation" => "standard",
"id" => org.id, "@permissions" => { "read"=>true, "sync"=>false },
"login" => "example-org", "id" => org.id,
"name" => nil, "login" => "example-org",
"github_id" => nil, "name" => nil,
"avatar_url" => nil, "github_id" => nil,
"repositories" => [{ "avatar_url" => nil,
"@type" => "repository", "repositories" => [{
"@href" => "/v3/repo/#{repo.id}", "@type" => "repository",
"@permissions" => { "@href" => "/v3/repo/#{repo.id}",
"read" => true, "@representation" => "standard",
"enable" => false, "@permissions" => {
"disable" => false, "read" => true,
"create_request"=> false}, "enable" => false,
"id" => repo.id, "disable" => false,
"name" => "example-repo", "create_request" => false},
"slug" => "example-org/example-repo", "id" => repo.id,
"description" => nil, "name" => "example-repo",
"github_language" => nil, "slug" => "example-org/example-repo",
"active" => false, "description" => nil,
"private" => false, "github_language" => nil,
"last_build" => nil, "active" => false,
"owner" => { "@href"=> "/v3/org/#{org.id}" }, "private" => false,
"default_branch" => { "last_build" => nil,
"@type" => "branch", "owner" => { "@href"=> "/v3/org/#{org.id}" },
"@href" => "/v3/repo/#{repo.id}/branch/master", "default_branch" => {
"name" => "master", "@type" => "branch",
"last_build" => nil } "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master",
"last_build" => nil }
}] }]
}} }}
end end
@ -75,6 +79,7 @@ describe Travis::API::V3::Services::Owner::Find do
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@representation" => "standard",
"@permissions" => { "read"=>true, "sync"=>false }, "@permissions" => { "read"=>true, "sync"=>false },
"id" => org.id, "id" => org.id,
"login" => "example-org", "login" => "example-org",
@ -84,6 +89,7 @@ describe Travis::API::V3::Services::Owner::Find do
"repositories" => [{ "repositories" => [{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => false, "enable" => false,
@ -101,8 +107,9 @@ describe Travis::API::V3::Services::Owner::Find do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"name" => "master", "@representation"=> "minimal",
"last_build" => nil } "name" => "master",
"last_build" => nil }
}] }]
}} }}
end end
@ -111,14 +118,15 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-ORG") } before { get("/v3/owner/example-ORG") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@permissions" => { "read"=>true, "sync"=>false }, "@representation" => "standard",
"id" => org.id, "@permissions" => { "read"=>true, "sync"=>false },
"login" => "example-org", "id" => org.id,
"name" => nil, "login" => "example-org",
"github_id" => nil, "name" => nil,
"avatar_url" => nil "github_id" => nil,
"avatar_url" => nil
}} }}
end end
@ -132,6 +140,7 @@ describe Travis::API::V3::Services::Owner::Find do
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "organization", "@type" => "organization",
"@href" => "/v3/org/#{org.id}", "@href" => "/v3/org/#{org.id}",
"@representation"=> "standard",
"@permissions" => { "read"=>true, "sync"=>false }, "@permissions" => { "read"=>true, "sync"=>false },
"id" => org.id, "id" => org.id,
"login" => "example-org", "login" => "example-org",
@ -156,16 +165,17 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-user") } before { get("/v3/owner/example-user") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/#{user.id}", "@href" => "/v3/user/#{user.id}",
"@permissions" => {"read"=>true, "sync"=>false}, "@representation"=> "standard",
"id" => user.id, "@permissions" => {"read"=>true, "sync"=>false},
"login" => "example-user", "id" => user.id,
"name" => nil, "login" => "example-user",
"github_id" => nil, "name" => nil,
"avatar_url" => nil, "github_id" => nil,
"is_syncing" => nil, "avatar_url" => nil,
"synced_at" => nil "is_syncing" => nil,
"synced_at" => nil
}} }}
end end
@ -173,16 +183,17 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-USER") } before { get("/v3/owner/example-USER") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/#{user.id}", "@href" => "/v3/user/#{user.id}",
"@permissions" => {"read"=>true, "sync"=>false}, "@representation" => "standard",
"id" => user.id, "@permissions" => {"read"=>true, "sync"=>false},
"login" => "example-user", "id" => user.id,
"name" => nil, "login" => "example-user",
"github_id" => nil, "name" => nil,
"avatar_url" => nil, "github_id" => nil,
"is_syncing" => nil, "avatar_url" => nil,
"synced_at" => nil "is_syncing" => nil,
"synced_at" => nil
}} }}
end end
@ -194,21 +205,22 @@ describe Travis::API::V3::Services::Owner::Find do
before { get("/v3/owner/example-user?user.id=#{other.id}") } before { get("/v3/owner/example-user?user.id=#{other.id}") }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/#{user.id}", "@href" => "/v3/user/#{user.id}",
"@permissions" => {"read"=>true, "sync"=>false}, "@representation" => "standard",
"id" => user.id, "@permissions" => {"read"=>true, "sync"=>false},
"login" => "example-user", "id" => user.id,
"name" => nil, "login" => "example-user",
"github_id" => nil, "name" => nil,
"avatar_url" => nil, "github_id" => nil,
"is_syncing" => nil, "avatar_url" => nil,
"synced_at" => nil, "is_syncing" => nil,
"@warnings" => [{ "synced_at" => nil,
"@type" => "warning", "@warnings" => [{
"message" => "query parameter user.id not whitelisted, ignored", "@type" => "warning",
"warning_type" => "ignored_parameter", "message" => "query parameter user.id not whitelisted, ignored",
"parameter" => "user.id"}] "warning_type" => "ignored_parameter",
"parameter" => "user.id"}]
}} }}
end end
end end

View File

@ -18,6 +18,7 @@ describe Travis::API::V3::Services::Owner::Repositories do
"repositories" => [{ "repositories" => [{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => false, "enable" => false,
@ -47,10 +48,12 @@ describe Travis::API::V3::Services::Owner::Repositories do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -74,4 +77,4 @@ describe Travis::API::V3::Services::Owner::Repositories do
example { expect(last_response) .to be_ok } example { expect(last_response) .to be_ok }
example { expect(JSON.load(body)['repositories']) .to be == [] } example { expect(JSON.load(body)['repositories']) .to be == [] }
end end
end end

View File

@ -18,6 +18,7 @@ describe Travis::API::V3::Services::Repositories::ForCurrentUser do
"repositories" => [{ "repositories" => [{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => true, "enable" => true,
@ -47,10 +48,12 @@ describe Travis::API::V3::Services::Repositories::ForCurrentUser do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",

View File

@ -27,6 +27,7 @@ describe Travis::API::V3::Services::Repository::Find do
example { expect(parsed_body).to be == { example { expect(parsed_body).to be == {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => false, "enable" => false,
@ -56,10 +57,12 @@ describe Travis::API::V3::Services::Repository::Find do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -119,6 +122,7 @@ describe Travis::API::V3::Services::Repository::Find do
example { expect(parsed_body).to be == { example { expect(parsed_body).to be == {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => false, "enable" => false,
@ -148,10 +152,12 @@ describe Travis::API::V3::Services::Repository::Find do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -196,6 +202,7 @@ describe Travis::API::V3::Services::Repository::Find do
example { expect(parsed_body).to be == { example { expect(parsed_body).to be == {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => true, "enable" => true,
@ -225,10 +232,12 @@ describe Travis::API::V3::Services::Repository::Find do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",
@ -279,6 +288,7 @@ describe Travis::API::V3::Services::Repository::Find do
example { expect(parsed_body).to be == { example { expect(parsed_body).to be == {
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/#{repo.id}", "@href" => "/v3/repo/#{repo.id}",
"@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"enable" => true, "enable" => true,
@ -308,10 +318,12 @@ describe Travis::API::V3::Services::Repository::Find do
"default_branch" => { "default_branch" => {
"@type" => "branch", "@type" => "branch",
"@href" => "/v3/repo/#{repo.id}/branch/master", "@href" => "/v3/repo/#{repo.id}/branch/master",
"@representation" => "minimal",
"name" => "master", "name" => "master",
"last_build" => { "last_build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{repo.last_build.id}", "@href" => "/v3/build/#{repo.last_build.id}",
"@representation"=> "minimal",
"id" => repo.last_build.id, "id" => repo.last_build.id,
"number" => "3", "number" => "3",
"state" => "configured", "state" => "configured",

View File

@ -49,16 +49,17 @@ describe Travis::API::V3::Services::Requests::Create do
example { expect(last_response.status).to be == 403 } example { expect(last_response.status).to be == 403 }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "error", "@type" => "error",
"error_type" => "insufficient_access", "error_type" => "insufficient_access",
"error_message" => "operation requires create_request access to repository", "error_message" => "operation requires create_request access to repository",
"resource_type" => "repository", "resource_type" => "repository",
"permission" => "create_request", "permission" => "create_request",
"repository" => { "repository" => {
"@type" => "repository", "@type" => "repository",
"@href" => "/repo/#{repo.id}", "@href" => "/repo/#{repo.id}",
"id" => repo.id, "@representation" => "minimal",
"slug" => "svenfuchs/minimal"} "id" => repo.id,
"slug" => "svenfuchs/minimal"}
}} }}
end end
@ -89,10 +90,19 @@ describe Travis::API::V3::Services::Requests::Create do
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "pending", "@type" => "pending",
"remaining_requests" => 10, "remaining_requests" => 10,
"repository" => {"@type"=>"repository", "@href"=>"/repo/#{repo.id}", "id"=>repo.id, "slug"=>"svenfuchs/minimal"}, "repository" => {
"@type" => "repository",
"@href" => "/repo/#{repo.id}",
"@representation" => "minimal",
"id" => repo.id,
"slug" => "svenfuchs/minimal"},
"request" => { "request" => {
"repository" => {"id"=>repo.id, "owner_name"=>"svenfuchs", "name"=>"minimal"}, "repository" => {
"user" => {"id"=>repo.owner.id}, "id" => repo.id,
"owner_name" => "svenfuchs",
"name" => "minimal"},
"user" => {
"id" => repo.owner.id},
"message" => nil, "message" => nil,
"branch" => "master", "branch" => "master",
"config" => {}}, "config" => {}},
@ -229,7 +239,7 @@ describe Travis::API::V3::Services::Requests::Create do
"@type" => "error", "@type" => "error",
"error_type" => "request_limit_reached", "error_type" => "request_limit_reached",
"error_message" => "request limit reached for resource", "error_message" => "request limit reached for resource",
"repository" => {"@type"=>"repository", "@href"=>"/repo/#{repo.id}", "id"=>repo.id, "slug"=>"svenfuchs/minimal" } "repository" => {"@type"=>"repository", "@href"=>"/repo/#{repo.id}", "@representation"=>"minimal", "id"=>repo.id, "slug"=>"svenfuchs/minimal" }
}} }}
end end

View File

@ -10,16 +10,17 @@ describe Travis::API::V3::Services::User::Current do
before { get("/v3/user", {}, headers) } before { get("/v3/user", {}, headers) }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/#{user.id}", "@href" => "/v3/user/#{user.id}",
"@permissions" => {"read"=>true, "sync"=>true}, "@representation" => "standard",
"id" => user.id, "@permissions" => {"read"=>true, "sync"=>true},
"login" => "svenfuchs", "id" => user.id,
"name" =>"Sven Fuchs", "login" => "svenfuchs",
"github_id" => user.github_id, "name" =>"Sven Fuchs",
"avatar_url" => "https://0.gravatar.com/avatar/07fb84848e68b96b69022d333ca8a3e2", "github_id" => user.github_id,
"is_syncing" => user.is_syncing, "avatar_url" => "https://0.gravatar.com/avatar/07fb84848e68b96b69022d333ca8a3e2",
"synced_at" => user.synced_at "is_syncing" => user.is_syncing,
"synced_at" => user.synced_at
}} }}
end end
end end

View File

@ -10,16 +10,17 @@ describe Travis::API::V3::Services::User::Find do
before { get("/v3/user/#{user.id}", {}, headers) } before { get("/v3/user/#{user.id}", {}, headers) }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
example { expect(JSON.load(body)).to be == { example { expect(JSON.load(body)).to be == {
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/#{user.id}", "@href" => "/v3/user/#{user.id}",
"@permissions" => {"read"=>true, "sync"=>true}, "@representation" => "standard",
"id" => user.id, "@permissions" => {"read"=>true, "sync"=>true},
"login" => "svenfuchs", "id" => user.id,
"name" =>"Sven Fuchs", "login" => "svenfuchs",
"github_id" => user.github_id, "name" =>"Sven Fuchs",
"avatar_url" => "https://0.gravatar.com/avatar/07fb84848e68b96b69022d333ca8a3e2", "github_id" => user.github_id,
"is_syncing" => user.is_syncing, "avatar_url" => "https://0.gravatar.com/avatar/07fb84848e68b96b69022d333ca8a3e2",
"synced_at" => user.synced_at "is_syncing" => user.is_syncing,
"synced_at" => user.synced_at
}} }}
end end
end end