Merge branch 'cd-v3-parity'

This commit is contained in:
Konstantin Haase 2015-08-25 19:42:00 +02:00
commit 6b0850813c
6 changed files with 12 additions and 1 deletions

View File

@ -34,6 +34,7 @@ module Travis::API::V3
def fields
fields = { :"@type" => type }
fields[:@href] = href if href
fields[:@representation] = representation
fields[:@pagination] = pagination_info if meta_data.include? :pagination
fields
end
@ -48,13 +49,17 @@ module Travis::API::V3
result = fields
included = self.included.dup
result[collection_key] = list.map do |entry|
rendered = render_entry(entry, included: included, mode: :standard, **options)
rendered = render_entry(entry, included: included, mode: representation, **options)
included << entry
rendered
end
result
end
def representation
:standard
end
def render_entry(entry, **options)
Renderer.render_value(entry, **options)
end

View File

@ -20,6 +20,7 @@ describe Travis::API::V3::Services::Accounts::ForCurrentUser do
example { expect(JSON.load(body)).to be == {
"@type" => "accounts",
"@href" => "/v3/accounts",
"@representation" => "standard",
"accounts" => [{
"@type" => "account",
"@representation" =>"standard",

View File

@ -27,6 +27,7 @@ describe Travis::API::V3::Services::Builds::Find do
example { expect(parsed_body).to be == {
"@type" => "builds",
"@href" => "/v3/repo/#{repo.id}/builds?limit=1",
"@representation" => "standard",
"@pagination" => {
"limit" => 1,
"offset" => 0,
@ -94,6 +95,7 @@ describe Travis::API::V3::Services::Builds::Find do
example { expect(parsed_body).to be == {
"@type" => "builds",
"@href" => "/v3/repo/#{repo.id}/builds?limit=1",
"@representation" => "standard",
"@pagination" => {
"limit" => 1,
"offset" => 0,

View File

@ -20,6 +20,7 @@ describe Travis::API::V3::Services::Organizations::ForCurrentUser do
example { expect(JSON.load(body)).to be == {
"@type" => "organizations",
"@href" => "/v3/orgs",
"@representation" => "standard",
"organizations" => [{
"@type" => "organization",
"@href" => "/v3/org/#{org.id}",

View File

@ -15,6 +15,7 @@ describe Travis::API::V3::Services::Owner::Repositories do
example { expect(JSON.load(body)).to be == {
"@type" => "repositories",
"@href" => "/v3/owner/svenfuchs/repos",
"@representation" => "standard",
"repositories" => [{
"@type" => "repository",
"@href" => "/v3/repo/#{repo.id}",

View File

@ -15,6 +15,7 @@ describe Travis::API::V3::Services::Repositories::ForCurrentUser do
example { expect(JSON.load(body)).to be == {
"@type" => "repositories",
"@href" => "/v3/repos",
"@representation" => "standard",
"repositories" => [{
"@type" => "repository",
"@href" => "/v3/repo/#{repo.id}",