Accept .atom
extension
And return Atom feed for builds. Specs look different, because it needs to explicitly handle the common case where the client sends `Accept: */*`.
This commit is contained in:
parent
ea3a5a7a0d
commit
3b20120c72
|
@ -18,6 +18,10 @@ class Travis::Api::App
|
|||
def png?
|
||||
request.accept =~ %r(image/png)
|
||||
end
|
||||
|
||||
def atom?
|
||||
request.accept =~ %r(application/atom+xml)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'travis/api/app'
|
|||
class Travis::Api::App
|
||||
class Middleware
|
||||
class Rewrite < Middleware
|
||||
FORMAT = %r(\.(json|xml|png|txt)$)
|
||||
FORMAT = %r(\.(json|xml|png|txt|atom)$)
|
||||
V1_REPO_URL = %r(^(/[^/]+/[^/]+(?:/builds(?:/[\d]+)?|/cc)?)$)
|
||||
|
||||
helpers :accept
|
||||
|
@ -56,6 +56,10 @@ class Travis::Api::App
|
|||
env['travis.format'] == 'xml'
|
||||
end
|
||||
|
||||
def atom?
|
||||
env['travis.format'] == 'atom'
|
||||
end
|
||||
|
||||
def v1?
|
||||
accept_version == 'v1'
|
||||
end
|
||||
|
|
|
@ -102,5 +102,13 @@ describe 'v1 repos' do
|
|||
response = get '/repositories/svenfuchs/minimal/builds', {}, headers
|
||||
response.content_type.should =~ /^application\/atom\+xml/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with .atom extension and "Accept: */*" header' do
|
||||
let(:headers) { { 'HTTP_ACCEPT' => '*/*' } }
|
||||
it 'GET /repositories/svenfuchs/minimal/builds.atom' do
|
||||
response = get '/repositories/svenfuchs/minimal/builds.atom', {}, headers
|
||||
response.content_type.should =~ /^application\/atom\+xml/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -147,4 +147,12 @@ describe 'Repos' do
|
|||
response.content_type.should =~ /^application\/atom\+xml/
|
||||
end
|
||||
end
|
||||
|
||||
context 'with .atom extension' do
|
||||
let(:headers) { { 'HTTP_ACCEPT' => '*/*' } }
|
||||
it 'GET /repositories/svenfuchs/minimal/builds.atom' do
|
||||
response = get '/repositories/svenfuchs/minimal/builds.atom', {}, headers
|
||||
response.content_type.should =~ /^application\/atom\+xml/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user