2015-09-02 02:28:48 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::RawController do
|
2018-08-30 08:34:41 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
subject do
|
|
|
|
get(:show,
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: filepath)
|
|
|
|
end
|
2015-09-02 02:28:48 -04:00
|
|
|
|
|
|
|
context 'regular filename' do
|
2018-08-30 08:34:41 -04:00
|
|
|
let(:filepath) { 'master/README.md' }
|
2015-09-02 02:28:48 -04:00
|
|
|
|
|
|
|
it 'delivers ASCII file' do
|
2018-08-30 08:34:41 -04:00
|
|
|
subject
|
2015-09-02 02:28:48 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2015-09-02 02:28:48 -04:00
|
|
|
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(response.header['Content-Disposition'])
|
|
|
|
.to eq('inline')
|
2017-03-07 12:57:30 -05:00
|
|
|
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
|
2015-09-02 02:28:48 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-03 05:55:43 -04:00
|
|
|
|
|
|
|
context 'image header' do
|
2018-08-30 08:34:41 -04:00
|
|
|
let(:filepath) { 'master/files/images/6049019_460s.jpg' }
|
2015-09-03 05:55:43 -04:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'sets image content type header' do
|
2018-08-30 08:34:41 -04:00
|
|
|
subject
|
2015-09-03 05:55:43 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2015-09-03 05:55:43 -04:00
|
|
|
expect(response.header['Content-Type']).to eq('image/jpeg')
|
2017-03-07 12:57:30 -05:00
|
|
|
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
|
2015-09-03 05:55:43 -04:00
|
|
|
end
|
|
|
|
end
|
2015-12-07 09:03:50 -05:00
|
|
|
|
2018-08-30 08:34:41 -04:00
|
|
|
it_behaves_like 'repository lfs file load' do
|
|
|
|
let(:filename) { 'lfs_object.iso' }
|
|
|
|
let(:filepath) { "be93687/files/lfs/#{filename}" }
|
2015-12-07 09:03:50 -05:00
|
|
|
end
|
2015-09-02 02:28:48 -04:00
|
|
|
end
|
|
|
|
end
|