cleanup and some notes

This commit is contained in:
Sven Fuchs 2012-10-03 13:14:01 +02:00
parent ac8dd768ec
commit 6bda358786
6 changed files with 52 additions and 103 deletions

View File

@ -6,6 +6,11 @@ class Travis::Api::App
get '/' do
respond_with all(params).run, type: :branches
end
# get '/:owner_name/:name/branches' do # v1
# get '/repos/:owner_name/:name/branches' do # v2
# respond_with all(params).run, type: :branches
# end
end
end
end

View File

@ -7,6 +7,11 @@ class Travis::Api::App
respond_with all(params).run
end
# get '/:owner_name/:name/builds' do # v1
# get '/repos/:owner_name/:name/builds' do # v2
# respond_with all(params).run
# end
get '/:id' do
respond_with one(params).run
end

View File

@ -12,13 +12,13 @@ class Travis::Api::App
end
# TODO the format constraint neither seems to work nor fail?
get '/:id/cc.:format', format: 'xml' do
get '/:id/cc.:format', format: 'xml' do # v1
respond_with one(params).run
end
# get '/:owner_name/:name.:format', format: 'png' do
# pass unless params.key?('owner_name') && params.key?('name')
# result_image service(:repositories, :one, params).run(:raise => false)
# get '/:owner_name/:name.?:format?' do # v1
# get '/repos/:owner_name/:name.?:format?' do # v2
# respond_with service(:repositories, :one, params).run(:raise => params[:format] != 'png')
# end
end
end

View File

@ -2,6 +2,7 @@ require 'travis/api/app'
class Travis::Api::App
class Endpoint
# TODO should this be /profile?
class Users < Endpoint
# Gives information about the currently logged in user.
#

View File

@ -1,62 +0,0 @@
# require 'spec_helper'
#
# describe 'Result images' do
# let!(:repo) { Factory(:repository, owner_name: 'svenfuchs', name: 'minimal') }
#
# describe 'GET /svenfuchs/minimal.png' do
# it '"unknown" when the repository does not exist' do
# get('/svenfuchs/does-not-exist.png').should deliver_result_image_for('unknown')
# end
#
# it '"unknown" when it only has one build that is not finished' do
# repo.update_attributes!(last_build_result: nil)
# 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_result: 1)
# 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_result: 0)
# get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
# end
#
# it '"passing" when there is a running build but the previous one has passed' do
# Factory(:build, repository: repo, state: :finished, result: nil, previous_result: 0)
# repo.update_attributes!(last_build_result: nil)
# get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
# end
# end
#
# describe 'GET /svenfuchs/minimal.png' do
# let(:commit) { Factory(:commit, branch: 'dev') }
#
# it '"unknown" when the repository does not exist' do
# get('/svenfuchs/does-not-exist.png?branch=dev').should deliver_result_image_for('unknown')
# end
#
# it '"unknown" when it only has a build that is not finished' do
# Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
# get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('unknown')
# end
#
# it '"failing" when the last build has failed' do
# Factory(:build, repository: repo, state: :finished, result: 1, commit: commit)
# get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('failing')
# end
#
# it '"passing" when the last build has passed' do
# Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
# get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
# end
#
# it '"passing" when there is a running build but the previous one has passed' do
# Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
# Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
# repo.update_attributes!(last_build_result: nil)
# get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
# end
# end
# end

View File

@ -46,55 +46,55 @@ describe 'Repos' do
get('/svenfuchs/does-not-exist.png').should deliver_result_image_for('unknown')
end
xit '"unknown" when it only has a build that is not finished' do
repo.builds.delete_all
Factory(:running_build, repository: repo)
xit '"unknown" when it only has one build that is not finished' do
repo.update_attributes!(last_build_result: nil)
get('/svenfuchs/minimal.png').should deliver_result_image_for('unknown')
end
xit '"failing" when the last build has failed' do
repo.last_build.update_attributes!(:result => 1)
repo.update_attributes!(last_build_result: 1)
get('/svenfuchs/minimal.png').should deliver_result_image_for('failing')
end
xit '"passing" when the last build has passed' do
repo.last_build.update_attributes!(:result => 0)
get('/svenfuchs/minimal.png').should deliver_result_image_for('failing')
end
# TODO what? there's not even an image for this
xit '"stable" when there is a running build but the previous one has passed' do
Factory(:running_build, repository: repo)
repo.last_build.update_attributes!(:result => 0)
get('/svenfuchs/minimal.png').should deliver_result_image_for('stable')
end
end
describe 'GET /svenfuchs/minimal.png' do
xit '"unknown" when the repository does not exist' do
get('/svenfuchs/minimal.png').should deliver_result_image_for('unknown')
end
xit '"unknown" when it only has a build that is not finished' do
repo.builds.delete_all
Factory(:running_build, repository: repo)
get('/svenfuchs/minimal.png').should deliver_result_image_for('unknown')
end
xit '"failing" when the last build has failed' do
repo.last_build.update_attributes!(:result => 1)
get('/svenfuchs/minimal.png').should deliver_result_image_for('failing')
end
xit '"passing" when the last build has passed' do
repo.last_build.update_attributes!(:result => 0)
repo.update_attributes!(last_build_result: 0)
get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
end
xit '"passing" when there is a running build but the previous one has passed' do
repo.last_build.update_attributes!(:result => 0)
Factory(:running_build, :repository => repo)
get_png(repository, :branch => 'master').should serve_result_image('passing')
Factory(:build, repository: repo, state: :finished, result: nil, previous_result: 0)
repo.update_attributes!(last_build_result: nil)
get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
end
end
describe 'GET /svenfuchs/minimal.png' do
let(:commit) { Factory(:commit, branch: 'dev') }
xit '"unknown" when the repository does not exist' do
get('/svenfuchs/does-not-exist.png?branch=dev').should deliver_result_image_for('unknown')
end
xit '"unknown" when it only has a build that is not finished' do
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('unknown')
end
xit '"failing" when the last build has failed' do
Factory(:build, repository: repo, state: :finished, result: 1, commit: commit)
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('failing')
end
xit '"passing" when the last build has passed' do
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
end
xit '"passing" when there is a running build but the previous one has passed' do
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
repo.update_attributes!(last_build_result: nil)
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
end
end
end