Commit 549d64c6 authored by Thong Kuah's avatar Thong Kuah

Merge branch '9490-store-designs-in-lfs-ce' into 'master'

CE backport for gitlab-ee!13389 (Support storing design blobs using LFS)

See merge request gitlab-org/gitlab-ce!29101
parents 4b37f5be c7dcbc03
...@@ -39,7 +39,7 @@ describe Projects::AvatarsController do ...@@ -39,7 +39,7 @@ describe Projects::AvatarsController do
end end
context 'when the avatar is stored in lfs' do context 'when the avatar is stored in lfs' do
it_behaves_like 'repository lfs file load' do it_behaves_like 'a controller that can serve LFS files' do
let(:filename) { 'lfs_object.iso' } let(:filename) { 'lfs_object.iso' }
let(:filepath) { "files/lfs/#{filename}" } let(:filepath) { "files/lfs/#{filename}" }
end end
......
...@@ -42,7 +42,7 @@ describe Projects::RawController do ...@@ -42,7 +42,7 @@ describe Projects::RawController do
end end
end end
it_behaves_like 'repository lfs file load' do it_behaves_like 'a controller that can serve LFS files' do
let(:filename) { 'lfs_object.iso' } let(:filename) { 'lfs_object.iso' }
let(:filepath) { "be93687/files/lfs/#{filename}" } let(:filepath) { "be93687/files/lfs/#{filename}" }
end end
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
# - `filepath`: path of the file (contains filename) # - `filepath`: path of the file (contains filename)
# - `subject`: the request to be made to the controller. Example: # - `subject`: the request to be made to the controller. Example:
# subject { get :show, namespace_id: project.namespace, project_id: project } # subject { get :show, namespace_id: project.namespace, project_id: project }
shared_examples 'repository lfs file load' do shared_examples 'a controller that can serve LFS files' do
context 'when file is stored in lfs' do
let(:lfs_oid) { '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' } let(:lfs_oid) { '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' }
let(:lfs_size) { '1575078' } let(:lfs_size) { '1575078' }
let!(:lfs_object) { create(:lfs_object, oid: lfs_oid, size: lfs_size) } let!(:lfs_object) { create(:lfs_object, oid: lfs_oid, size: lfs_size) }
...@@ -28,11 +27,13 @@ shared_examples 'repository lfs file load' do ...@@ -28,11 +27,13 @@ shared_examples 'repository lfs file load' do
end end
it 'serves the file' do it 'serves the file' do
lfs_uploader = LfsObjectUploader.new(lfs_object)
# Notice the filename= is omitted from the disposition; this is because # Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file # Rails 5 will append this header in send_file
expect(controller).to receive(:send_file) expect(controller).to receive(:send_file)
.with( .with(
"#{LfsObjectUploader.root}/91/ef/f75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897", File.join(lfs_uploader.root, lfs_uploader.store_dir, lfs_uploader.filename),
filename: filename, filename: filename,
disposition: %Q(attachment; filename*=UTF-8''#{filename})) disposition: %Q(attachment; filename*=UTF-8''#{filename}))
...@@ -62,7 +63,7 @@ shared_examples 'repository lfs file load' do ...@@ -62,7 +63,7 @@ shared_examples 'repository lfs file load' do
file_uri = URI.parse(response.location) file_uri = URI.parse(response.location)
params = CGI.parse(file_uri.query) params = CGI.parse(file_uri.query)
expect(params["response-content-disposition"].first).to eq(%q(attachment; filename="lfs_object.iso"; filename*=UTF-8''lfs_object.iso)) expect(params["response-content-disposition"].first).to eq(%Q(attachment; filename="#{filename}"; filename*=UTF-8''#{filename}))
end end
end end
end end
...@@ -91,5 +92,4 @@ shared_examples 'repository lfs file load' do ...@@ -91,5 +92,4 @@ shared_examples 'repository lfs file load' do
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
end end
end end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment