diff --git a/changelogs/unreleased/api-fix-files.yml b/changelogs/unreleased/api-fix-files.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a9e29109a8d4c0d1c364b37aa42d299a4e93e92 --- /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 eb5b947172a10f391321fbc97cd63b2c98657128..dfab60f7fa53e8ab9b4444e953bbb02a1aab7a79 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 f197fadebabaeef4a2ead3766f237f26234fbed1..834c4e52693f133c340069f0b031d41052fbde17 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 0000000000000000000000000000000000000000..d1888b3376af63e45ae73db78decb70bf8d28844 --- /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