Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-22 00:08:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-22 00:08:57 +0300
commita6c2be7cd20a9515b347e72d63c5b47bb9b79457 (patch)
tree568212b4debeb2a35bb1133209b98e1468d9ee85 /spec/migrations
parent74a2d57b337034cfdcd719615e4da06643b69114 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/create_environment_for_self_monitoring_project_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/migrations/create_environment_for_self_monitoring_project_spec.rb b/spec/migrations/create_environment_for_self_monitoring_project_spec.rb
new file mode 100644
index 00000000000..ba1081c5006
--- /dev/null
+++ b/spec/migrations/create_environment_for_self_monitoring_project_spec.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200214214934_create_environment_for_self_monitoring_project')
+
+describe CreateEnvironmentForSelfMonitoringProject, :migration do
+ let(:application_settings_table) { table(:application_settings) }
+
+ let(:environments) { table(:environments) }
+
+ let(:instance_administrators_group) do
+ table(:namespaces).create!(
+ id: 1,
+ name: 'GitLab Instance Administrators',
+ path: 'gitlab-instance-administrators-random',
+ type: 'Group'
+ )
+ end
+
+ let(:self_monitoring_project) do
+ table(:projects).create!(
+ id: 2,
+ name: 'Self Monitoring',
+ path: 'self_monitoring',
+ namespace_id: instance_administrators_group.id
+ )
+ end
+
+ context 'when the self monitoring project ID is not set' do
+ it 'does not make changes' do
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to be_nil
+
+ migrate!
+
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to be_nil
+ end
+ end
+
+ context 'when the self monitoring project ID is set' do
+ before do
+ application_settings_table.create!(instance_administration_project_id: self_monitoring_project.id)
+ end
+
+ context 'when the environment already exists' do
+ let!(:environment) do
+ environments.create!(project_id: self_monitoring_project.id, name: 'production', slug: 'production')
+ end
+
+ it 'does not make changes' do
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to eq(environment)
+
+ migrate!
+
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to eq(environment)
+ end
+ end
+
+ context 'when the environment does not exist' do
+ it 'creates the environment' do
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to be_nil
+
+ migrate!
+
+ expect(environments.find_by(project_id: self_monitoring_project.id)).to be
+ end
+ end
+ end
+end