Tests for delete file by API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
32d7332d2c
commit
a185cce5d3
1 changed files with 34 additions and 0 deletions
|
@ -78,4 +78,38 @@ describe API::API do
|
|||
response.status.should == 400
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /projects/:id/repository/files" do
|
||||
let(:valid_params) {
|
||||
{
|
||||
file_path: 'spec/spec_helper.rb',
|
||||
branch_name: 'master',
|
||||
commit_message: 'Changed file'
|
||||
}
|
||||
}
|
||||
|
||||
it "should delete existing file in project repo" do
|
||||
Gitlab::Satellite::DeleteFileAction.any_instance.stub(
|
||||
commit!: true,
|
||||
)
|
||||
|
||||
delete api("/projects/#{project.id}/repository/files", user), valid_params
|
||||
response.status.should == 200
|
||||
json_response['file_path'].should == 'spec/spec_helper.rb'
|
||||
end
|
||||
|
||||
it "should return a 400 bad request if no params given" do
|
||||
delete api("/projects/#{project.id}/repository/files", user)
|
||||
response.status.should == 400
|
||||
end
|
||||
|
||||
it "should return a 400 if satellite fails to create file" do
|
||||
Gitlab::Satellite::DeleteFileAction.any_instance.stub(
|
||||
commit!: false,
|
||||
)
|
||||
|
||||
delete api("/projects/#{project.id}/repository/files", user), valid_params
|
||||
response.status.should == 400
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue