Commit a185cce5d39e2bf7f865cd3c4b2f74f355d6d051
1 parent
32d7332d
Exists in
master
and in
4 other branches
Tests for delete file by API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
34 additions
and
0 deletions
Show diff stats
spec/requests/api/files_spec.rb
... | ... | @@ -78,4 +78,38 @@ describe API::API do |
78 | 78 | response.status.should == 400 |
79 | 79 | end |
80 | 80 | end |
81 | + | |
82 | + describe "DELETE /projects/:id/repository/files" do | |
83 | + let(:valid_params) { | |
84 | + { | |
85 | + file_path: 'spec/spec_helper.rb', | |
86 | + branch_name: 'master', | |
87 | + commit_message: 'Changed file' | |
88 | + } | |
89 | + } | |
90 | + | |
91 | + it "should delete existing file in project repo" do | |
92 | + Gitlab::Satellite::DeleteFileAction.any_instance.stub( | |
93 | + commit!: true, | |
94 | + ) | |
95 | + | |
96 | + delete api("/projects/#{project.id}/repository/files", user), valid_params | |
97 | + response.status.should == 200 | |
98 | + json_response['file_path'].should == 'spec/spec_helper.rb' | |
99 | + end | |
100 | + | |
101 | + it "should return a 400 bad request if no params given" do | |
102 | + delete api("/projects/#{project.id}/repository/files", user) | |
103 | + response.status.should == 400 | |
104 | + end | |
105 | + | |
106 | + it "should return a 400 if satellite fails to create file" do | |
107 | + Gitlab::Satellite::DeleteFileAction.any_instance.stub( | |
108 | + commit!: false, | |
109 | + ) | |
110 | + | |
111 | + delete api("/projects/#{project.id}/repository/files", user), valid_params | |
112 | + response.status.should == 400 | |
113 | + end | |
114 | + end | |
81 | 115 | end | ... | ... |