diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2016-07-22 17:23:35 +0200 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2016-07-22 17:56:10 +0200 |
commit | 71952d057d5edad0697d7da76f5da034689e0f4a (patch) | |
tree | 4b70bd3ac4ff15958b950fd97389d46b19f00184 | |
parent | 23425401d1b574dd87babfffda4d59b9f91d1538 (diff) | |
download | gitlab-ce-71952d057d5edad0697d7da76f5da034689e0f4a.tar.gz |
Handle custom Git LFS content type
-rw-r--r-- | config/initializers/mime_types.rb | 7 | ||||
-rw-r--r-- | spec/requests/lfs_http_spec.rb | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 3e553120205..f498732feca 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -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 +}) diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index 7692f986d27..26572699bf8 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -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 |