diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 00:08:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 00:08:08 +0300 |
commit | e0b84f4ba4b44c8ecf00be97843c40df2550b74c (patch) | |
tree | 7cecae4276358dd46d7fa15f84068f7b4c626089 /spec/lib/gitlab/database_importers | |
parent | 73391dcc368ef846c2960c1d0ef5e64ca78e1bee (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/database_importers')
-rw-r--r-- | spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb new file mode 100644 index 00000000000..b0cec61ce06 --- /dev/null +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do + describe '#execute' do + let(:result) { subject.execute } + let(:application_setting) { Gitlab::CurrentSettings.current_application_settings } + + before do + allow(ApplicationSetting).to receive(:current_without_cache) { application_setting } + end + + 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 'with project destroyed but ID still present in application settings' do + before do + application_setting.instance_administration_project_id = 1 + end + + it 'deletes project ID from application settings' do + subject.execute + + expect(application_setting.instance_administration_project_id).to be_nil + end + end + + context 'when self monitoring project exists' do + let(:group) { create(:group) } + let(:project) { create(:project, namespace: group) } + + before do + application_setting.instance_administration_project = project + 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.instance_administration_project_id).to be_nil + end + end + end +end |