diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-10 18:11:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-10 18:11:12 +0300 |
commit | 6a6824a5ce46273248944d1859591d3a811aa18e (patch) | |
tree | 77cc4f04ff7d59fc518fba04e3a226dc0949ed37 /spec/migrations | |
parent | 8fd149139d3d64b102f51455180f03adbc80f469 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20210804150320_create_base_work_item_types_spec.rb | 10 | ||||
-rw-r--r-- | spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/spec/migrations/20210804150320_create_base_work_item_types_spec.rb b/spec/migrations/20210804150320_create_base_work_item_types_spec.rb index 535472f5931..9ba29637e00 100644 --- a/spec/migrations/20210804150320_create_base_work_item_types_spec.rb +++ b/spec/migrations/20210804150320_create_base_work_item_types_spec.rb @@ -6,7 +6,17 @@ require_migration!('create_base_work_item_types') RSpec.describe CreateBaseWorkItemTypes, :migration do let!(:work_item_types) { table(:work_item_types) } + 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 + it 'creates default data' do + # Need to delete all as base types are seeded before entire test suite + WorkItem::Type.delete_all + reversible_migration do |migration| migration.before -> { # Depending on whether the migration has been run before, diff --git a/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb b/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb index b9cc9de88cc..c23110750c3 100644 --- a/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb +++ b/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb @@ -6,8 +6,18 @@ require_migration!('upsert_base_work_item_types') RSpec.describe UpsertBaseWorkItemTypes, :migration do let!(:work_item_types) { table(:work_item_types) } + 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 + context 'when no default types exist' do it 'creates default data' do + # Need to delete all as base types are seeded before entire test suite + WorkItem::Type.delete_all + expect(work_item_types.count).to eq(0) reversible_migration do |migration| @@ -26,10 +36,6 @@ RSpec.describe UpsertBaseWorkItemTypes, :migration do end context 'when default types already exist' do - before do - Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.import - end - it 'does not create default types again' do expect(work_item_types.all.pluck(:base_type)).to match_array(WorkItem::Type.base_types.values) |