Return removed_at and removed_by if the log was removed
This commit is contained in:
parent
bd9714dca9
commit
43e20332cf
10
Gemfile.lock
10
Gemfile.lock
|
@ -34,6 +34,13 @@ GIT
|
|||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/s3.git
|
||||
revision: 386361c1b0ede19cde0ddaf86e41a16308575f5d
|
||||
specs:
|
||||
s3 (0.3.21)
|
||||
proxies (~> 0.2.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: 8fa9680a47ab457187ddf3a88461a756a6f4c2a6
|
||||
|
@ -270,8 +277,6 @@ GEM
|
|||
rspec-expectations (2.99.2)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.99.2)
|
||||
s3 (0.3.21)
|
||||
proxies (~> 0.2.0)
|
||||
sass (3.4.6)
|
||||
sidekiq (2.5.0)
|
||||
celluloid (~> 0.12.0)
|
||||
|
@ -358,6 +363,7 @@ DEPENDENCIES
|
|||
rb-fsevent (~> 0.9.1)
|
||||
rerun
|
||||
rspec (~> 2.13)
|
||||
s3!
|
||||
sentry-raven!
|
||||
sinatra
|
||||
sinatra-contrib
|
||||
|
|
|
@ -58,7 +58,9 @@ class Travis::Api::App
|
|||
|
||||
get '/:job_id/log' do
|
||||
resource = service(:find_log, params).run
|
||||
if (!resource || resource.archived?)
|
||||
if (resource && resource.removed_at) && accepts?('application/json')
|
||||
respond_with resource, type: 'removed_log', root: 'log'
|
||||
elsif (!resource || resource.archived?)
|
||||
# the way we use responders makes it hard to validate proper format
|
||||
# automatically here, so we need to check it explicitly
|
||||
if accepts?('text/plain')
|
||||
|
|
|
@ -23,13 +23,18 @@ class Travis::Api::App
|
|||
return true unless resource.is_a?(Log)
|
||||
|
||||
chunked = accept_params[:chunked]
|
||||
if resource.removed_at
|
||||
true
|
||||
else
|
||||
chunked ? !resource.aggregated_at : true
|
||||
end
|
||||
end
|
||||
|
||||
def result
|
||||
if builder
|
||||
p = params
|
||||
p[:root] = options[:type] if options[:type]
|
||||
p[:root] = options[:root] if options[:root]
|
||||
p[:root] = options[:type] if options[:type] && !p[:root]
|
||||
builder.new(resource, p).data
|
||||
else
|
||||
basic_type_resource
|
||||
|
|
|
@ -16,6 +16,7 @@ module Travis
|
|||
require 'travis/api/v2/http/job'
|
||||
require 'travis/api/v2/http/jobs'
|
||||
require 'travis/api/v2/http/log'
|
||||
require 'travis/api/v2/http/removed_log'
|
||||
require 'travis/api/v2/http/permissions'
|
||||
require 'travis/api/v2/http/repositories'
|
||||
require 'travis/api/v2/http/repository'
|
||||
|
|
20
lib/travis/api/v2/http/removed_log.rb
Normal file
20
lib/travis/api/v2/http/removed_log.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Travis
|
||||
module Api
|
||||
module V2
|
||||
module Http
|
||||
class RemovedLog < Travis::Api::Serializer
|
||||
attributes :id, :job_id, :body, :removed_at, :removed_by
|
||||
|
||||
def body
|
||||
object.content
|
||||
end
|
||||
|
||||
def removed_by
|
||||
object.removed_by.name || object.removed_by.login if object.removed_by
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -103,6 +103,18 @@ describe 'Jobs' do
|
|||
response.should deliver_json_for(job.log, version: 'v2')
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds removed info if the log is removed' do
|
||||
time = Time.new(2015, 1, 9, 12, 57, 31)
|
||||
job.log.update_attributes(removed_at: time, removed_by: User.first)
|
||||
headers = { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' }
|
||||
response = get "/jobs/#{job.id}/log", {}, headers
|
||||
body = JSON.parse(response.body)
|
||||
|
||||
body['log']['removed_by'].should == 'Sven Fuchs'
|
||||
body['log']['removed_at'].should == "2015-01-09T11:57:31Z"
|
||||
body['log']['id'].should == job.log.id
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH /jobs/:job_id/log' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user