summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-08-08 22:35:40 -0700
committerStan Hu <stanhu@gmail.com>2015-08-09 15:23:22 -0700
commitc5648de230905afd35a1b044a74b6d687eaed994 (patch)
tree46312f7d97e60a230bec3210efbc9dcc3dfa749e /spec
parentb833f208f3a31a6ac964dac422141249f2278fd9 (diff)
downloadgitlab-ce-c5648de230905afd35a1b044a74b6d687eaed994.tar.gz
Fix corrupted binary files when using API files endpoint
Add CHANGELOG for gitlab_git 7.2.9 updates Closes #2219
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