summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-08 14:19:52 +0000
committerDouwe Maan <douwe@gitlab.com>2015-12-08 14:19:52 +0000
commit51ed5225adf4aac3ccbf715f8647258dac784abb (patch)
tree16137752ed3ea1ffd8c5398ceb131868dc2105d1 /spec/controllers
parentf5430e48b42227f1c1874ca27c6907f0f704be28 (diff)
parent6245be083d985df3dd5daebb78ecf300bacff7b6 (diff)
downloadgitlab-ce-51ed5225adf4aac3ccbf715f8647258dac784abb.tar.gz
Merge branch 'serve_lfs_object' into 'master'
Serve LFS object Depends on gitlab-org/gitlab_git!57 See merge request !1976
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/raw_controller_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb
index c114f342021..1caa476d37d 100644
--- a/spec/controllers/projects/raw_controller_spec.rb
+++ b/spec/controllers/projects/raw_controller_spec.rb
@@ -33,5 +33,39 @@ describe Projects::RawController do
expect(response.header['Content-Type']).to eq('image/jpeg')
end
end
+
+ context 'lfs object' do
+ let(:id) { 'be93687/files/lfs/lfs_object.iso' }
+ let!(:lfs_object) { create(:lfs_object, oid: '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897', size: '1575078') }
+
+ context 'when project has access' do
+ before do
+ public_project.lfs_objects << lfs_object
+ allow_any_instance_of(LfsObjectUploader).to receive(:exists?).and_return(true)
+ allow(controller).to receive(:send_file) { controller.render nothing: true }
+ end
+
+ it 'serves the file' do
+ expect(controller).to receive(:send_file).with("#{Gitlab.config.shared.path}/lfs-objects/91/ef/f75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897", filename: "lfs_object.iso", disposition: 'attachment')
+ get(:show,
+ namespace_id: public_project.namespace.to_param,
+ project_id: public_project.to_param,
+ id: id)
+
+ expect(response.status).to eq(200)
+ end
+ end
+
+ context 'when project does not have access' do
+ it 'does not serve the file' do
+ get(:show,
+ namespace_id: public_project.namespace.to_param,
+ project_id: public_project.to_param,
+ id: id)
+
+ expect(response.status).to eq(404)
+ end
+ end
+ end
end
end