summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-08-10 14:04:07 +0000
committerStan Hu <stanhu@gmail.com>2015-08-10 14:04:07 +0000
commit39bda5d05e96ff9b2b8a89852b9520e8f262051e (patch)
tree2d36f106e5371a629c86319e49c2150812057445 /spec
parent151d9fb35fd66a161cf0e1f95d7b0f0448ca8034 (diff)
parentc5648de230905afd35a1b044a74b6d687eaed994 (diff)
downloadgitlab-ce-39bda5d05e96ff9b2b8a89852b9520e8f262051e.tar.gz
Merge branch 'disable-autocrlf-for-binary-files' into 'master'
Fix corrupted binary files when using API files endpoint Closes #2219 See merge request !1123
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/files_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index 8cb8790c339..042e6352567 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -117,4 +117,35 @@ describe API::API, api: true do
expect(response.status).to eq(400)
end
end
+
+ describe "POST /projects/:id/repository/files with binary file" do
+ let(:file_path) { 'test.bin' }
+ let(:put_params) do
+ {
+ file_path: file_path,
+ branch_name: 'master',
+ content: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=',
+ commit_message: 'Binary file with a \n should not be touched',
+ encoding: 'base64'
+ }
+ end
+ let(:get_params) do
+ {
+ file_path: file_path,
+ ref: 'master',
+ }
+ end
+
+ before do
+ post api("/projects/#{project.id}/repository/files", user), put_params
+ end
+
+ it "remains unchanged" do
+ get api("/projects/#{project.id}/repository/files", user), get_params
+ expect(response.status).to eq(200)
+ expect(json_response['file_path']).to eq(file_path)
+ expect(json_response['file_name']).to eq(file_path)
+ expect(json_response['content']).to eq(put_params[:content])
+ end
+ end
end