blob: 4a4cebc9d7053202e9ff94656c2529d5b0cde8c5 (
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
62
63
64
65
66
67
68
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::PagesHelper do
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
stub_config(pages: {
access_control: true,
external_http: true,
external_https: true,
host: "new.domain.com"
})
end
context 'when the user have permission' do
before do
project.add_maintainer(user)
end
context 'on custom domain' do
using RSpec::Parameterized::TableSyntax
where(:external_http, :external_https, :can_create) do
false | false | false
false | true | true
true | false | true
true | true | true
end
with_them do
it do
stub_config(pages: { external_http: external_http, external_https: external_https })
expect(can_create_pages_custom_domains?(user, project)).to be can_create
end
end
end
context 'on domain limit' do
it 'can create new domains when the limit is 0' do
Gitlab::CurrentSettings.update!(max_pages_custom_domains_per_project: 0)
expect(can_create_pages_custom_domains?(user, project)).to be true
end
it 'validates custom domain creation is only allowed upto max value' do
Gitlab::CurrentSettings.update!(max_pages_custom_domains_per_project: 1)
expect(can_create_pages_custom_domains?(user, project)).to be true
create(:pages_domain, project: project)
expect(can_create_pages_custom_domains?(user, project)).to be false
end
end
end
context 'when the user does not have permission' do
before do
project.add_guest(user)
end
it 'validates user cannot create domain' do
expect(can_create_pages_custom_domains?(user, project)).to be false
end
end
end
|