Use Accept entries for getting API version

This commit is contained in:
Piotr Sarnacki 2015-07-07 12:45:30 +02:00
parent a1b421a7fa
commit 857af4fde0
2 changed files with 6 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class Travis::Api::App
end
def accept_version
@accept_version ||= request.accept.join =~ HEADER_FORMAT && "v#{$1}" || DEFAULT_VERSION
@accept_version ||= accept_entries.map(&:version).compact.first || DEFAULT_VERSION
end
def accept_format

View File

@ -34,6 +34,11 @@ describe 'v1 repos' do
response.should redirect_to('/repositories/svenfuchs/minimal.json')
end
it 'GET /svenfuchs/minimal' do
response = get '/svenfuchs/minimal.json', {}, 'HTTP_ACCEPT' => 'application/json; version=2'
response.status.should == 404
end
it 'GET /svenfuchs/minimal/cc.xml' do
response = get '/svenfuchs/minimal/cc.xml'
response.should redirect_to('/repositories/svenfuchs/minimal/cc.xml')