diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2019-01-10 12:30:19 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-01-10 12:30:19 +0000 |
commit | 40887a94bda88b184491a3182f08eb86cf1aeb4d (patch) | |
tree | bbc4a525aa6b8e0f95ca94948f3f5da0f5f0aeac /spec/lib/api | |
parent | 0bbdbd55607a65361570fb3072664ec8a7b6cb23 (diff) | |
download | gitlab-ce-40887a94bda88b184491a3182f08eb86cf1aeb4d.tar.gz |
Fix files/blob api endpoint content disposition
Diffstat (limited to 'spec/lib/api')
-rw-r--r-- | spec/lib/api/helpers_spec.rb | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index 1c73a936e17..e1aea82653d 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -150,32 +150,36 @@ describe API::Helpers do end describe '#send_git_blob' do - context 'content disposition' do - let(:repository) { double } - let(:blob) { double(name: 'foobar') } + let(:repository) { double } + let(:blob) { double(name: 'foobar') } - let(:send_git_blob) do - subject.send(:send_git_blob, repository, blob) - end + let(:send_git_blob) do + subject.send(:send_git_blob, repository, blob) + end - before do - allow(subject).to receive(:env).and_return({}) - allow(subject).to receive(:content_type) - allow(subject).to receive(:header).and_return({}) - allow(Gitlab::Workhorse).to receive(:send_git_blob) - end + before do + allow(subject).to receive(:env).and_return({}) + allow(subject).to receive(:content_type) + allow(subject).to receive(:header).and_return({}) + allow(Gitlab::Workhorse).to receive(:send_git_blob) + end + + it 'sets Gitlab::Workhorse::DETECT_HEADER header' do + expect(send_git_blob[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" + end + context 'content disposition' do context 'when blob name is null' do let(:blob) { double(name: nil) } it 'returns only the disposition' do - expect(send_git_blob['Content-Disposition']).to eq 'attachment' + expect(send_git_blob['Content-Disposition']).to eq 'inline' end end context 'when blob name is not null' do it 'returns disposition with the blob name' do - expect(send_git_blob['Content-Disposition']).to eq 'attachment; filename="foobar"' + expect(send_git_blob['Content-Disposition']).to eq 'inline; filename="foobar"' end end end |