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

remove_schedule_and_status_from_pending_alert_escalations_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86e161cea4381318592f679f4dcd5062dbc05256 (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
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe RemoveScheduleAndStatusFromPendingAlertEscalations, feature_category: :incident_management do
  let(:escalations) { table(:incident_management_pending_alert_escalations) }
  let(:schedule_index) { 'index_incident_management_pending_alert_escalations_on_schedule' }
  let(:schedule_foreign_key) { 'fk_rails_fcbfd9338b' }

  it 'correctly migrates up and down' do
    reversible_migration do |migration|
      migration.before -> {
        expect(escalations.column_names).to include('schedule_id', 'status')
        expect(escalations_indexes).to include(schedule_index)
        expect(escalations_constraints).to include(schedule_foreign_key)
      }

      migration.after -> {
        escalations.reset_column_information
        expect(escalations.column_names).not_to include('schedule_id', 'status')
        expect(escalations_indexes).not_to include(schedule_index)
        expect(escalations_constraints).not_to include(schedule_foreign_key)
      }
    end
  end

  private

  def escalations_indexes
    ActiveRecord::Base.connection.indexes(:incident_management_pending_alert_escalations).collect(&:name)
  end

  def escalations_constraints
    ActiveRecord::Base.connection.foreign_keys(:incident_management_pending_alert_escalations).collect(&:name)
  end
end