Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-12-31 12:13:09 +0300
committerFrancisco Javier López <fjlopez@gitlab.com>2018-12-31 15:02:32 +0300
commit2cd47bba9a4ee1b503b37c548826ef527c4e49ba (patch)
tree5eac568727d03feb18677b7eab85c77f8eb2e5bd /spec/lib/api
parent77909a88460bbc864a5f95f3fa66053eb6cab5a8 (diff)
Fixed api content-disposition in blob and files endpoint
Diffstat (limited to 'spec/lib/api')
-rw-r--r--spec/lib/api/helpers_spec.rb32
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