diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-14 15:09:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-14 15:09:39 +0300 |
commit | 24952631402d6fb352749c688bc059d6ca74217d (patch) | |
tree | 45cd8aab49f6e2fba01a78d47a20160a7a2824dd /spec/migrations | |
parent | 641b65c021767da7cb82bf64d9784e91c8cfb308 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-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 |