blob: 9e69d3637b8389261aa0c54beafbbf8520258ea0 (
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
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe UpdateInvalidWebHooks, feature_category: :integrations do
let(:web_hooks) { table(:web_hooks) }
let(:groups) { table(:namespaces) }
let(:projects) { table(:projects) }
before do
group = groups.create!(name: 'gitlab', path: 'gitlab-org')
project = projects.create!(namespace_id: group.id)
web_hooks.create!(group_id: group.id, type: 'GroupHook')
web_hooks.create!(project_id: project.id, type: 'ProjectHook')
web_hooks.create!(group_id: group.id, project_id: project.id, type: 'ProjectHook')
end
it 'clears group_id when ProjectHook type and project_id are present', :aggregate_failures do
expect(web_hooks.where.not(group_id: nil).where.not(project_id: nil).count).to eq(1)
migrate!
expect(web_hooks.where.not(group_id: nil).where.not(project_id: nil).count).to eq(0)
expect(web_hooks.where(type: 'GroupHook').count).to eq(1)
expect(web_hooks.where(type: 'ProjectHook').count).to eq(2)
end
end
|