Commit 0aa33c7a authored by Sean Arnold's avatar Sean Arnold

Use insert_all in specs

Look for active services only
parent 9d6b948c
......@@ -24,18 +24,25 @@ class MigrateServicesToHttpIntegrations < ActiveRecord::Migration[6.0]
JOIN alerts_service_data
ON (services.id = alerts_service_data.service_id)
WHERE type = '#{ALERT_SERVICE_TYPE}'
AND active = TRUE
SQL
select_all(sql).each do |alerts_service|
HttpIntegration.create!(
current_time = Time.current
values = select_all(sql).map do |alerts_service|
{
project_id: alerts_service['project_id'],
name: SERVICE_NAMES_IDENTIFIER[:name],
endpoint_identifier: SERVICE_NAMES_IDENTIFIER[:identifier],
encrypted_token: alerts_service['encrypted_token'],
encrypted_token_iv: alerts_service['encrypted_token_iv'],
active: alerts_service['active']
)
active: alerts_service['active'],
updated_at: current_time,
created_at: current_time
}
end
HttpIntegration.insert_all(values) if values.present?
end
def down
......
......@@ -6,7 +6,7 @@ require Rails.root.join('db', 'migrate', '20201027002551_migrate_services_to_htt
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) }
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) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment