diff options
author | Sean McGivern <sean@gitlab.com> | 2018-12-31 13:42:54 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-12-31 13:42:54 +0000 |
commit | ca14b70d5201852751d79d6a0827b81689fff5be (patch) | |
tree | 63f8f322f9bdbb2f288c48676eb16b5906399cdf /spec/lib | |
parent | a352a95e9a4e6e925e43e1b0a3dc2cac6d33cef4 (diff) | |
parent | 2cd47bba9a4ee1b503b37c548826ef527c4e49ba (diff) | |
download | gitlab-ce-ca14b70d5201852751d79d6a0827b81689fff5be.tar.gz |
Merge branch 'fj-55781-fix-api-blob-content-disposition' into 'master'
Fixed content-disposition in blob and files API endpoint
Closes #55781
See merge request gitlab-org/gitlab-ce!24078
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/api/helpers_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index 58a49124ce6..1c73a936e17 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -148,4 +148,36 @@ describe API::Helpers do it_behaves_like 'user namespace finder' end + + describe '#send_git_blob' do + context 'content disposition' do + let(:repository) { double } + let(:blob) { double(name: 'foobar') } + + 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 + + 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' + 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"' + end + end + end + end end |