Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/migrations/update_invalid_web_hooks_spec.rb')
-rw-r--r--spec/migrations/update_invalid_web_hooks_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/migrations/update_invalid_web_hooks_spec.rb b/spec/migrations/update_invalid_web_hooks_spec.rb
new file mode 100644
index 00000000000..a65f82d7082
--- /dev/null
+++ b/spec/migrations/update_invalid_web_hooks_spec.rb
@@ -0,0 +1,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