diff options
Diffstat (limited to 'spec/migrations/remove_schedule_and_status_from_pending_alert_escalations_spec.rb')
-rw-r--r-- | spec/migrations/remove_schedule_and_status_from_pending_alert_escalations_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/migrations/remove_schedule_and_status_from_pending_alert_escalations_spec.rb b/spec/migrations/remove_schedule_and_status_from_pending_alert_escalations_spec.rb new file mode 100644 index 00000000000..f595261ff90 --- /dev/null +++ b/spec/migrations/remove_schedule_and_status_from_pending_alert_escalations_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe RemoveScheduleAndStatusFromPendingAlertEscalations 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 |