diff options
author | Rémy Coutable <remy@rymai.me> | 2017-02-06 11:18:30 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-02-15 09:50:33 +0100 |
commit | 785793ad81b59277d2dfce21fbebac189465d69f (patch) | |
tree | f094314269edf2950e041083bcbd4659d02fd878 | |
parent | 64fd9266cf44c3806970beb843a595a5dacf0707 (diff) | |
download | gitlab-ce-785793ad81b59277d2dfce21fbebac189465d69f.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.yml | 4 | ||||
-rw-r--r-- | lib/api/helpers.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/builds_spec.rb | 1 | ||||
-rw-r--r-- | spec/support/matchers/match_file.rb | 5 |
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 a1d7b323f4f..016f10de048 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 7be7acebb19..3a1e39e6494 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 build 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 |