Commit d40d831b authored by Kerri Miller's avatar Kerri Miller

Merge branch 'fix_return_404_when_repository_is_missing' into 'master'

Don't return 500 error in Commits API when repository is missing

See merge request gitlab-org/gitlab!80410
parents bf211da5 95177859
...@@ -44,6 +44,8 @@ module API ...@@ -44,6 +44,8 @@ module API
use :pagination use :pagination
end end
get ':id/repository/commits', urgency: :low do get ':id/repository/commits', urgency: :low do
not_found! 'Repository' unless user_project.repository_exists?
path = params[:path] path = params[:path]
before = params[:until] before = params[:until]
after = params[:since] after = params[:since]
......
...@@ -127,6 +127,15 @@ RSpec.describe API::Commits do ...@@ -127,6 +127,15 @@ RSpec.describe API::Commits do
it_behaves_like 'project commits' it_behaves_like 'project commits'
end end
context 'when repository does not exist' do
let(:project) { create(:project, creator: user, path: 'my.project') }
it_behaves_like '404 response' do
let(:request) { get api(route, current_user) }
let(:message) { '404 Repository Not Found' }
end
end
context "path optional parameter" do context "path optional parameter" do
it "returns project commits matching provided path parameter" do it "returns project commits matching provided path parameter" do
path = 'files/ruby/popen.rb' path = 'files/ruby/popen.rb'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment