blob: 935ad2ba472a38368acb7390f8440eef13a392bf (
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
|
# frozen_string_literal: true
RSpec.shared_examples 'work item related links restrictions importer' do
shared_examples_for 'adds restrictions' do
it "adds all restrictions if they don't exist" do
expect { subject }.to change { WorkItems::RelatedLinkRestriction.count }.from(0).to(34)
end
end
context 'when restrictions are missing' do
before do
WorkItems::RelatedLinkRestriction.delete_all
end
it_behaves_like 'adds restrictions'
end
context 'when base types are missing' do
before do
WorkItems::Type.delete_all
end
it_behaves_like 'adds restrictions'
end
context 'when some restrictions are missing' do
before do
Gitlab::DatabaseImporters::WorkItems::RelatedLinksRestrictionsImporter.upsert_restrictions
WorkItems::RelatedLinkRestriction.limit(1).delete_all
end
it 'inserts missing restrictions and does nothing if some already existed' do
expect { subject }.to make_queries_matching(/INSERT/, 1).and(
change { WorkItems::RelatedLinkRestriction.count }.by(1)
)
expect(WorkItems::RelatedLinkRestriction.count).to eq(34)
end
end
end
|