From 54a6926aaf1ebd44ce09089c727cc4f828a9dcee Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 23:52:53 +0100 Subject: [PATCH] Properly handle non existent resources This commit changes travis-api to always return 404 response if resource is not available. Previously we were returning image/png with "unknown" status instead if user used "*/*" Accept header, which was confusing. --- lib/travis/api/app/responders/base.rb | 2 +- spec/integration/v1/repositories_spec.rb | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/travis/api/app/responders/base.rb b/lib/travis/api/app/responders/base.rb index 9c099cdd..8849f553 100644 --- a/lib/travis/api/app/responders/base.rb +++ b/lib/travis/api/app/responders/base.rb @@ -33,7 +33,7 @@ module Travis::Api::App::Responders end def apply? - acceptable_format? + resource && acceptable_format? end def format diff --git a/spec/integration/v1/repositories_spec.rb b/spec/integration/v1/repositories_spec.rb index aea3fd4c..b1b35fd1 100644 --- a/spec/integration/v1/repositories_spec.rb +++ b/spec/integration/v1/repositories_spec.rb @@ -40,10 +40,6 @@ describe 'v1 repos' do end 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 Build.delete_all Factory(:build, repository: repo, state: :created, result: nil) @@ -72,10 +68,6 @@ describe 'v1 repos' do let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_bar) { Factory(:commit, branch: 'bar') } - it '"unknown" when the repository does not exist' do - get('/svenfuchs/does-not-exist.png?branch=foo,bar').should deliver_result_image_for('unknown') - end - it '"unknown" when it only has unfinished builds on the relevant branches' do Build.delete_all Factory(:build, repository: repo, state: :started, commit: on_foo)