summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-02 06:08:53 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-02 06:08:53 +0000
commit26c50e0eb9e1513e60e3a38e538f25f682146ac6 (patch)
tree8843693805baa17506dfe35ddbc5477f6a9a26b5 /spec/migrations
parent9a34a91714afddc98c255284e9a63e1659cee48a (diff)
downloadgitlab-ce-26c50e0eb9e1513e60e3a38e538f25f682146ac6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb b/spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
new file mode 100644
index 00000000000..c1fbde69100
--- /dev/null
+++ b/spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20201027002551_migrate_services_to_http_integrations.rb')
+
+RSpec.describe MigrateServicesToHttpIntegrations do
+ let!(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') }
+ let!(:project) { table(:projects).create!(id: 1, namespace_id: namespace.id) }
+ let!(:alert_service) { table(:services).create!(type: 'AlertsService', project_id: project.id, active: true) }
+ let!(:alert_service_data) { table(:alerts_service_data).create!(service_id: alert_service.id, encrypted_token: 'test', encrypted_token_iv: 'test')}
+ let(:http_integrations) { table(:alert_management_http_integrations) }
+
+ describe '#up' do
+ it 'creates the http integrations from the alert services', :aggregate_failures do
+ expect { migrate! }.to change { http_integrations.count }.by(1)
+
+ http_integration = http_integrations.last
+ expect(http_integration.project_id).to eq(alert_service.project_id)
+ expect(http_integration.encrypted_token).to eq(alert_service_data.encrypted_token)
+ expect(http_integration.encrypted_token_iv).to eq(alert_service_data.encrypted_token_iv)
+ expect(http_integration.active).to eq(alert_service.active)
+ expect(http_integration.name).to eq(described_class::SERVICE_NAMES_IDENTIFIER[:name])
+ expect(http_integration.endpoint_identifier).to eq(described_class::SERVICE_NAMES_IDENTIFIER[:identifier])
+ end
+ end
+end