Commit 71952d05 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Handle custom Git LFS content type

parent 23425401
...@@ -12,3 +12,10 @@ Mime::Type.register_alias "text/html", :md ...@@ -12,3 +12,10 @@ Mime::Type.register_alias "text/html", :md
Mime::Type.register "video/mp4", :mp4, [], [:m4v, :mov] Mime::Type.register "video/mp4", :mp4, [], [:m4v, :mov]
Mime::Type.register "video/webm", :webm Mime::Type.register "video/webm", :webm
Mime::Type.register "video/ogg", :ogv 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
})
...@@ -35,7 +35,7 @@ describe 'Git LFS API and storage' do ...@@ -35,7 +35,7 @@ describe 'Git LFS API and storage' do
before do before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(false) 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 end
it 'responds with 501' do it 'responds with 501' do
...@@ -74,7 +74,7 @@ describe 'Git LFS API and storage' do ...@@ -74,7 +74,7 @@ describe 'Git LFS API and storage' do
context 'when handling lfs request using deprecated API' do context 'when handling lfs request using deprecated API' do
let(:authorization) { authorize_user } let(:authorization) { authorize_user }
before do 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 end
it_behaves_like 'a deprecated' it_behaves_like 'a deprecated'
...@@ -164,7 +164,7 @@ describe 'Git LFS API and storage' do ...@@ -164,7 +164,7 @@ describe 'Git LFS API and storage' do
enable_lfs enable_lfs
update_lfs_permissions update_lfs_permissions
update_user_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 end
describe 'download' do describe 'download' do
...@@ -775,8 +775,8 @@ describe 'Git LFS API and storage' do ...@@ -775,8 +775,8 @@ describe 'Git LFS API and storage' do
Projects::ForkService.new(project, user, {}).execute Projects::ForkService.new(project, user, {}).execute
end end
def post_json(url, body = nil, headers = nil) def post_lfs_json(url, body = nil, headers = nil)
post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => 'application/json')) post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => 'application/vnd.git-lfs+json'))
end end
def json_response def json_response
......
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