Handle custom Git LFS content type

This commit is contained in:
Jacob Vosmaer 2016-07-22 17:23:35 +02:00
parent 23425401d1
commit 71952d057d
2 changed files with 12 additions and 5 deletions

View File

@ -12,3 +12,10 @@ Mime::Type.register_alias "text/html", :md
Mime::Type.register "video/mp4", :mp4, [], [:m4v, :mov]
Mime::Type.register "video/webm", :webm
Mime::Type.register "video/ogg", :ogv
middlewares = Gitlab::Application.config.middleware
middlewares.swap(ActionDispatch::ParamsParser, ActionDispatch::ParamsParser, {
Mime::Type.lookup('application/vnd.git-lfs+json') => lambda do |body|
ActiveSupport::JSON.decode(body)
end
})

View File

@ -35,7 +35,7 @@ describe 'Git LFS API and storage' do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(false)
post_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
end
it 'responds with 501' do
@ -74,7 +74,7 @@ describe 'Git LFS API and storage' do
context 'when handling lfs request using deprecated API' do
let(:authorization) { authorize_user }
before do
post_json "#{project.http_url_to_repo}/info/lfs/objects", nil, headers
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects", nil, headers
end
it_behaves_like 'a deprecated'
@ -164,7 +164,7 @@ describe 'Git LFS API and storage' do
enable_lfs
update_lfs_permissions
update_user_permissions
post_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
end
describe 'download' do
@ -775,8 +775,8 @@ describe 'Git LFS API and storage' do
Projects::ForkService.new(project, user, {}).execute
end
def post_json(url, body = nil, headers = nil)
post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => 'application/json'))
def post_lfs_json(url, body = nil, headers = nil)
post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => 'application/vnd.git-lfs+json'))
end
def json_response