c7dcbc03bb
This backports to ce a refactor of the shared example 'a controller that can serve LFS files'. The ee MR that contains the original refactor is https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/13389 The reason for the refactor was mostly the removal of the outer context as it didn't need to be there, and prevented let(:lfs_oid) from being overwritten. The shared example was also renamed to be more descriptive.
50 lines
1.5 KiB
Ruby
50 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
describe Projects::RawController do
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
describe 'GET #show' do
|
|
subject do
|
|
get(:show,
|
|
params: {
|
|
namespace_id: project.namespace,
|
|
project_id: project,
|
|
id: filepath
|
|
})
|
|
end
|
|
|
|
context 'regular filename' do
|
|
let(:filepath) { 'master/README.md' }
|
|
|
|
it 'delivers ASCII file' do
|
|
subject
|
|
|
|
expect(response).to have_gitlab_http_status(200)
|
|
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
|
|
expect(response.header['Content-Disposition']).to eq('inline')
|
|
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
|
|
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
|
|
end
|
|
end
|
|
|
|
context 'image header' do
|
|
let(:filepath) { 'master/files/images/6049019_460s.jpg' }
|
|
|
|
it 'leaves image content disposition' do
|
|
subject
|
|
|
|
expect(response).to have_gitlab_http_status(200)
|
|
expect(response.header['Content-Disposition']).to eq('inline')
|
|
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
|
|
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
|
|
end
|
|
end
|
|
|
|
it_behaves_like 'a controller that can serve LFS files' do
|
|
let(:filename) { 'lfs_object.iso' }
|
|
let(:filepath) { "be93687/files/lfs/#{filename}" }
|
|
end
|
|
end
|
|
end
|