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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-22 15:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-22 15:08:47 +0300
commit6046a605fdbb6d180861c978d17fe3516b2e7507 (patch)
tree42cc483042b341475ba14d8fbfad6432a15327f4 /spec/support/shared_examples/controllers
parent5956978e1d2aa2b5b35c2d79f67f6b9706b8ec4e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/controllers')
-rw-r--r--spec/support/shared_examples/controllers/snippet_blob_shared_examples.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/support/shared_examples/controllers/snippet_blob_shared_examples.rb b/spec/support/shared_examples/controllers/snippet_blob_shared_examples.rb
new file mode 100644
index 00000000000..c3e8f807afb
--- /dev/null
+++ b/spec/support/shared_examples/controllers/snippet_blob_shared_examples.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'raw snippet blob' do
+ context 'with valid params' do
+ before do
+ subject
+ end
+
+ it 'delivers file with correct Workhorse headers' do
+ expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
+ expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq 'true'
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
+ end
+
+ it 'responds with status 200' do
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+
+ context 'with invalid file path' do
+ let(:filepath) { 'doesnotexist' }
+
+ it_behaves_like 'returning response status', :not_found
+ end
+
+ context 'with invalid ref' do
+ let(:ref) { 'doesnotexist' }
+
+ it_behaves_like 'returning response status', :not_found
+ end
+
+ it_behaves_like 'content disposition headers'
+end
+
+RSpec.shared_examples 'raw snippet without repository' do |unauthorized_status|
+ context 'when authorized' do
+ it 'returns a 422' do
+ subject
+
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
+ end
+ end
+
+ context 'when unauthorized' do
+ let(:visibility) { :private }
+
+ it_behaves_like 'returning response status', unauthorized_status
+ end
+end