blob: d67e50a50d41a2aa254ae19f6337afbaf70265eb (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do
describe '#execute' do
let!(:application_setting) { create(:application_setting) }
let(:result) { subject.execute }
context 'when project does not exist' do
it 'returns error' do
expect(result).to eq(
status: :error,
message: 'Self-monitoring project does not exist',
last_step: :validate_self_monitoring_project_exists
)
end
end
context 'when self-monitoring project exists' do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:application_setting) do
create(
:application_setting,
self_monitoring_project_id: project.id,
instance_administrators_group_id: group.id
)
end
it 'destroys project' do
subject.execute
expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'deletes project ID from application settings' do
subject.execute
expect(application_setting.reload.self_monitoring_project_id).to be_nil
end
it 'does not delete group' do
subject.execute
expect(application_setting.instance_administrators_group).to eq(group)
end
end
end
end
|