summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-02-06 11:18:30 +0000
committerRémy Coutable <remy@rymai.me>2017-02-06 11:18:30 +0000
commitda359c46b598ba44cff1829ab4abe49c4c225ae2 (patch)
tree3e1a3c328f2f18304e7caa637f23c5807a1e57d9
parent572fb0be9b1d45437b7c0ed1000399657f471ec7 (diff)
parentf5de8f159e9fb79ed523fcb41c4b062eeaf3f811 (diff)
downloadgitlab-ce-da359c46b598ba44cff1829ab4abe49c4c225ae2.tar.gz
Merge branch 'api-fix-files' into 'master'
API: Fix file downloading See merge request !8953
-rw-r--r--changelogs/unreleased/api-fix-files.yml4
-rw-r--r--lib/api/helpers.rb2
-rw-r--r--spec/requests/api/builds_spec.rb1
-rw-r--r--spec/support/matchers/match_file.rb5
4 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/unreleased/api-fix-files.yml b/changelogs/unreleased/api-fix-files.yml
new file mode 100644
index 00000000000..8a9e29109a8
--- /dev/null
+++ b/changelogs/unreleased/api-fix-files.yml
@@ -0,0 +1,4 @@
+---
+title: 'API: Fix file downloading'
+merge_request: Robert Schilling
+author: 8267
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index eb5b947172a..dfab60f7fa5 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -304,7 +304,7 @@ module API
header['X-Sendfile'] = path
body
else
- path
+ file path
end
end
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index f197fadebab..834c4e52693 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -188,6 +188,7 @@ describe API::Builds, api: true do
it 'returns specific job artifacts' do
expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers)
+ expect(response.body).to match_file(build.artifacts_file.file.file)
end
end
diff --git a/spec/support/matchers/match_file.rb b/spec/support/matchers/match_file.rb
new file mode 100644
index 00000000000..d1888b3376a
--- /dev/null
+++ b/spec/support/matchers/match_file.rb
@@ -0,0 +1,5 @@
+RSpec::Matchers.define :match_file do |expected|
+ match do |actual|
+ expect(Digest::MD5.hexdigest(actual)).to eq(Digest::MD5.hexdigest(File.read(expected)))
+ end
+end