Commit bb179a08 authored by Robert May's avatar Robert May

Ensure commits limit is always positive

Changelog: fixed
parent 0b48a8a8
......@@ -63,7 +63,9 @@ class Projects::CommitsController < Projects::ApplicationController
def set_commits
render_404 unless @path.empty? || request.format == :atom || @repository.blob_at(@commit.id, @path) || @repository.tree(@commit.id, @path).entries.present?
@limit = (params[:limit] || 40).to_i
limit = params[:limit].to_i
@limit = limit > 0 ? limit : 40 # limit can only ever be a positive number
@offset = (params[:offset] || 0).to_i
search = params[:search]
author = params[:author]
......
......@@ -67,6 +67,22 @@ RSpec.describe Projects::CommitsController do
end
end
context "with an invalid limit" do
before do
get(:show,
params: {
namespace_id: project.namespace,
project_id: project,
id: id,
limit: "foo"
})
end
let(:id) { 'master/README.md' }
it { is_expected.to respond_with(:success) }
end
context "when the ref name ends in .atom" do
context "when the ref does not exist with the suffix" do
before do
......
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