Fix webhook failure callout still displaying even after dismissed
What does this MR do and why?
This merge request fixes the webhook failure callout from sometimes still displaying even after being dismissed.
This bug only happened on some pages (for example, the main project page).
The problem happened because on some pages the object
passed to #web_hook_disabled_dismissed?
is a ProjectPresenter
(a wrapped Project
). Although most calls to the presenter are delegated to the wrapped project, the #class
call isn't. #class
is returned as ProjectPresenter
, so the check for whether the class has mixed in WebHooks::HasWebHooks
fails.
On the main project page, object
is a ProjectPresenter
, but on an issue page, it is a Project
, so it worked correctly on issue pages.
The change is to instead check if the object responds to a particular method we call on the next line.
How to set up and validate locally
- Enable the auto-disabling webhook feature
Feature.enable(:auto_disabling_web_hooks)
- Create a project webhook:
- Choose a project, go Settings > Webhooks.
- For URL enter
https://httpstat.us/500
which will return a500
error response. - For Trigger, select Issues events.
- Click Add webhook.
- Go Issues > List and choose and issue.
- Close, reopen, close, reopen, close and reopen the issue to generate lots of webhook triggers.
- Visit the project page, you should see a callout banner about the failed webhook.
- Dismiss it.
- Reload the page, it should not reappear.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.