debian-mirror-gitlab/spec/migrations/20210804150320_create_base_work_item_types_spec.rb

33 lines
1,011 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
require_migration!('create_base_work_item_types')
RSpec.describe CreateBaseWorkItemTypes, :migration do
let!(:work_item_types) { table(:work_item_types) }
2021-11-11 11:23:49 +05:30
after(:all) do
# Make sure base types are recreated after running the migration
# because migration specs are not run in a transaction
WorkItem::Type.delete_all
Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.import
end
2021-10-27 15:23:28 +05:30
it 'creates default data' do
2021-11-11 11:23:49 +05:30
# Need to delete all as base types are seeded before entire test suite
WorkItem::Type.delete_all
2021-10-27 15:23:28 +05:30
reversible_migration do |migration|
migration.before -> {
# Depending on whether the migration has been run before,
# the size could be 4, or 0, so we don't set any expectations
}
migration.after -> {
expect(work_item_types.count).to eq 4
expect(work_item_types.all.pluck(:base_type)).to match_array WorkItem::Type.base_types.values
}
end
end
end