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