From 0f6b02b339cf44f750cc369a010828b01fff511e Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 10 Mar 2015 11:29:03 +0100 Subject: [PATCH] v3: add @href to home document --- lib/travis/api/v3/service_index.rb | 2 +- spec/v3/service_index_spec.rb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/travis/api/v3/service_index.rb b/lib/travis/api/v3/service_index.rb index 39114408..2fb29200 100644 --- a/lib/travis/api/v3/service_index.rb +++ b/lib/travis/api/v3/service_index.rb @@ -37,7 +37,7 @@ module Travis::API::V3 end end end - { :@type => :home, :resources => resources } + { :@type => :home, :@href => "#{prefix}/", :resources => resources } end def render_json_home diff --git a/spec/v3/service_index_spec.rb b/spec/v3/service_index_spec.rb index b350c6d1..24949690 100644 --- a/spec/v3/service_index_spec.rb +++ b/spec/v3/service_index_spec.rb @@ -98,17 +98,20 @@ describe Travis::API::V3::ServiceIndex do describe 'with /v3 prefix' do let(:path) { '/v3/' } - specify(:resources) { expect(json['resources']).to be == expected_resources } + specify(:resources) { expect(json['resources']) .to be == expected_resources } + specify(:@href) { expect(json['@href']) .to be == '/v3/' } end describe 'with Accept header' do let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.3+json' } } - specify(:resources) { expect(json['resources']).to be == expected_resources } + specify(:resources) { expect(json['resources']) .to be == expected_resources } + specify(:@href) { expect(json['@href']) .to be == '/' } end describe 'with Travis-API-Version header' do let(:headers) { { 'HTTP_TRAVIS_API_VERSION' => '3' } } - specify(:resources) { expect(json['resources']).to be == expected_resources } + specify(:resources) { expect(json['resources']) .to be == expected_resources } + specify(:@href) { expect(json['@href']) .to be == '/' } end end