提交 ceaee58c 编写于 作者: R Robert Schilling

API: Catch empty commit messages

上级 cc9764ac
---
title: 'API: Catch empty commit messages'
merge_request: 21322
author: Robert Schilling
type: fixed
......@@ -59,7 +59,7 @@ module API
params :simple_file_params do
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
requires :commit_message, type: String, desc: 'Commit message'
requires :commit_message, type: String, regexp: /^\S+$/, desc: 'Commit message'
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
optional :author_email, type: String, desc: 'The email of the author'
optional :author_name, type: String, desc: 'The name of the author'
......
......@@ -337,6 +337,18 @@ describe API::Files do
expect(response).to have_gitlab_http_status(400)
end
it 'returns a 400 bad request if the commit message is empty' do
invalid_params = {
branch: 'master',
content: 'puts 8',
commit_message: ''
}
post api(route(file_path), user), invalid_params
expect(response).to have_gitlab_http_status(400)
end
it "returns a 400 if editor fails to create file" do
allow_any_instance_of(Repository).to receive(:create_file)
.and_raise(Gitlab::Git::CommitError, 'Cannot create file')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册