Commit 9bf87e30 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch '29215-500-error-when-deleting-group-web-hook-activerecord-statementinvalid-pg-querycanceled-error-canceling-statement-due-to-statement-timeout' into 'master'

Resolve "500 error when deleting group web hook due to statement timeout"

See merge request gitlab-org/gitlab!18642
parents 15f790a9 98f7e71a
......@@ -13,7 +13,7 @@ class WebHook < ApplicationRecord
algorithm: 'aes-256-gcm',
key: Settings.attr_encrypted_db_key_base_32
has_many :web_hook_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :web_hook_logs
validates :url, presence: true
validates :url, public_url: true, unless: ->(hook) { hook.is_a?(SystemHook) }
......
---
title: Use cascading deletes for deleting logs upon deleting a webhook
merge_request: 18642
author:
type: performance
......@@ -6,7 +6,7 @@ describe WebHook do
let(:hook) { build(:project_hook) }
describe 'associations' do
it { is_expected.to have_many(:web_hook_logs).dependent(:destroy) }
it { is_expected.to have_many(:web_hook_logs) }
end
describe 'validations' do
......@@ -85,4 +85,13 @@ describe WebHook do
hook.async_execute(data, hook_name)
end
end
describe '#destroy' do
it 'cascades to web_hook_logs' do
web_hook = create(:project_hook)
create_list(:web_hook_log, 3, web_hook: web_hook)
expect { web_hook.destroy }.to change(web_hook.web_hook_logs, :count).by(-3)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment