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
69
70
71
72
73
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::Pages, feature_category: :pages do
let_it_be_with_reload(:project) { create(:project, path: 'my.project', pages_https_only: false) }
let_it_be(:admin) { create(:admin) }
let_it_be(:user) { create(:user) }
before do
project.add_maintainer(user)
end
describe 'DELETE /projects/:id/pages' do
let(:path) { "/projects/#{project.id}/pages" }
it_behaves_like 'DELETE request permissions for admin mode' do
before do
stub_pages_setting(enabled: true)
end
let(:succes_status_code) { :no_content }
end
context 'when Pages is disabled' do
before do
stub_pages_setting(enabled: false)
end
it_behaves_like '404 response' do
let(:request) { delete api(path, admin, admin_mode: true) }
end
end
context 'when Pages is enabled' do
before do
stub_pages_setting(enabled: true)
end
context 'when Pages are deployed' do
it 'returns 204' do
delete api(path, admin, admin_mode: true)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'removes the pages' do
delete api(path, admin, admin_mode: true)
expect(project.reload.pages_deployed?).to be(false)
end
end
context 'when pages are not deployed' do
it 'returns 204' do
delete api(path, admin, admin_mode: true)
expect(response).to have_gitlab_http_status(:no_content)
end
end
context 'when there is no project' do
it 'returns 404' do
id = -1
delete api("/projects/#{id}/pages", admin, admin_mode: true)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
end
|