diff options
Diffstat (limited to 'spec/migrations/remove_alerts_service_records_spec.rb')
-rw-r--r-- | spec/migrations/remove_alerts_service_records_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/migrations/remove_alerts_service_records_spec.rb b/spec/migrations/remove_alerts_service_records_spec.rb new file mode 100644 index 00000000000..eaf9f90b445 --- /dev/null +++ b/spec/migrations/remove_alerts_service_records_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20210107194543_remove_alerts_service_records.rb') + +RSpec.describe RemoveAlertsServiceRecords do + let(:services) { table(:services) } + let(:alerts_service_data) { table(:alerts_service_data) } + + before do + 5.times do + service = services.create!(type: 'AlertsService') + alerts_service_data.create!(service_id: service.id) + end + + services.create!(type: 'SomeOtherType') + end + + it 'removes services records of type AlertsService and corresponding data', :aggregate_failures do + expect(services.count).to eq(6) + expect(alerts_service_data.count).to eq(5) + + migrate! + + expect(services.count).to eq(1) + expect(services.first.type).to eq('SomeOtherType') + expect(services.where(type: 'AlertsService')).to be_empty + expect(alerts_service_data.all).to be_empty + end +end |