fix xml responder and result image specs
This commit is contained in:
parent
a78e9d26cf
commit
d113833e9a
|
@ -42,7 +42,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: 2afee3dcfe6dfde30a797646e9772c397cd8d040
|
||||
revision: 714090635924650998b3a3d0f18b39d9cfd46839
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
actionmailer (~> 3.2.3)
|
||||
|
|
|
@ -3,15 +3,16 @@ module Travis::Api::App::Responders
|
|||
TEMPLATE = File.read(__FILE__).split("__END__").last.strip
|
||||
|
||||
STATUS = {
|
||||
nil => 'Unknown',
|
||||
0 => 'Success',
|
||||
1 => 'Failure'
|
||||
default: 'Unknown',
|
||||
passed: 'Success',
|
||||
failed: 'Failure',
|
||||
errored: 'Error',
|
||||
canceld: 'Canceled',
|
||||
}
|
||||
|
||||
ACTIVITY = {
|
||||
nil => 'Sleeping',
|
||||
'started' => 'Building',
|
||||
'finished' => 'Sleeping'
|
||||
default: 'Sleeping',
|
||||
started: 'Building'
|
||||
}
|
||||
|
||||
def apply?
|
||||
|
@ -28,13 +29,21 @@ module Travis::Api::App::Responders
|
|||
{
|
||||
name: resource.slug,
|
||||
url: [Travis.config.domain, resource.slug].join('/'),
|
||||
activity: ACTIVITY[last_build.try(:state)],
|
||||
activity: activity,
|
||||
label: last_build.try(:number),
|
||||
status: STATUS[resource.last_build_result_on(request.params)],
|
||||
status: status,
|
||||
time: last_build.finished_at.try(:strftime, '%Y-%m-%dT%H:%M:%S.%L%z')
|
||||
}
|
||||
end
|
||||
|
||||
def status
|
||||
STATUS[last_build.state.to_sym] || STATUS[:default]
|
||||
end
|
||||
|
||||
def activity
|
||||
ACTIVITY[last_build.state.to_sym] || ACTIVITY[:default]
|
||||
end
|
||||
|
||||
def last_build
|
||||
@last_build ||= resource.last_build
|
||||
end
|
||||
|
|
|
@ -49,17 +49,17 @@ describe 'v1 repos' do
|
|||
it '"unknown" when it only has one build that is not finished' do
|
||||
Build.delete_all
|
||||
Factory(:build, repository: repo, state: :created, result: nil)
|
||||
repo.update_attributes!(last_build_state: nil)
|
||||
repo.builds.update_all(state: 'started')
|
||||
get('/svenfuchs/minimal.png').should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"failing" when the last build has failed' do
|
||||
repo.update_attributes!(last_build_state: 'failed')
|
||||
repo.builds.update_all(state: 'failed')
|
||||
get('/svenfuchs/minimal.png').should deliver_result_image_for('failing')
|
||||
end
|
||||
|
||||
it '"passing" when the last build has passed' do
|
||||
repo.update_attributes!(last_build_state: 'passed')
|
||||
repo.builds.update_all(state: 'passed')
|
||||
get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user