blob: ae510826fe13e283fe50ac641af5fbca32a33d11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe CreateBaseWorkItemTypes, :migration do
include MigrationHelpers::WorkItemTypesHelper
let_it_be(:work_item_types) { table(:work_item_types) }
let(:base_types) do
{
issue: 0,
incident: 1,
test_case: 2,
requirement: 3
}
end
after(:all) do
# Make sure base types are recreated after running the migration
# because migration specs are not run in a transaction
reset_work_item_types
end
it 'creates default data' do
# Need to delete all as base types are seeded before entire test suite
work_item_types.delete_all
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(base_types.values)
}
end
end
end
|