summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2012-07-25 05:24:28 -0700
committerNihad Abbasov <narkoz.2008@gmail.com>2012-07-25 05:24:28 -0700
commitcb32e0320ab538b465574bb73c7bd3d32db56d3c (patch)
tree6136c187606044a9590567f8c94de17ac9b3b369
parentf7dd067490fe57505f7226c3b54d3127d2f7fd46 (diff)
downloadgitlab-ce-cb32e0320ab538b465574bb73c7bd3d32db56d3c.tar.gz
return 404 if project not found
-rw-r--r--lib/api/helpers.rb9
-rw-r--r--spec/api/projects_spec.rb6
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 4dfe35f49ef..c1ea05667ae 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -5,8 +5,13 @@ module Gitlab
end
def user_project
- @project ||= current_user.projects.find_by_id(params[:id]) ||
- current_user.projects.find_by_code(params[:id])
+ if @project ||= current_user.projects.find_by_id(params[:id]) ||
+ current_user.projects.find_by_code(params[:id])
+ else
+ error!({'message' => '404 Not found'}, 404)
+ end
+
+ @project
end
def authenticate!
diff --git a/spec/api/projects_spec.rb b/spec/api/projects_spec.rb
index 92a255438ab..8852a0d346b 100644
--- a/spec/api/projects_spec.rb
+++ b/spec/api/projects_spec.rb
@@ -36,6 +36,12 @@ describe Gitlab::API do
response.status.should == 200
json_response['name'].should == project.name
end
+
+ it "should return a 404 error if not found" do
+ get "#{api_prefix}/projects/42?private_token=#{user.private_token}"
+ response.status.should == 404
+ json_response['message'].should == '404 Not found'
+ end
end
describe "GET /projects/:id/repository/branches" do