blob: b9f58587a5813ba15986f50ae85c05eaa2750a26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Snippets::BlobsController do
using RSpec::Parameterized::TableSyntax
include SnippetHelpers
describe 'GET #raw' do
let_it_be(:author) { create(:user) }
let_it_be(:other_user) { create(:user) }
let(:visibility) { :public }
let(:snippet) { create(:personal_snippet, visibility, :repository, author: author) }
let(:filepath) { 'file1' }
let(:ref) { TestEnv::BRANCH_SHA['snippet/single-file'] }
let(:inline) { nil }
subject do
get(:raw,
params: {
snippet_id: snippet,
path: filepath,
ref: ref,
inline: inline
})
end
where(:snippet_visibility_level, :user, :status) do
:public | :author | :ok
:public | :other_user | :ok
:public | nil | :ok
:private | :author | :ok
:private | :other_user | :not_found
:private | nil | :redirect
end
with_them do
let(:visibility) { snippet_visibility_level }
before do
sign_in_as(user)
subject
end
it 'responds with correct status' do
expect(response).to have_gitlab_http_status(status)
end
end
it_behaves_like 'raw snippet blob'
context 'with a snippet without a repository' do
let(:snippet) { create(:personal_snippet, visibility, author: author) }
it_behaves_like 'raw snippet without repository', :redirect
end
end
end
|