debian-mirror-gitlab/spec/migrations/update_invalid_web_hooks_spec.rb

31 lines
1,009 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe UpdateInvalidWebHooks 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