Integration.default_integration should be returning nil if integration is not enabled at group, or instance level
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=534603) </details> <!--IssueSummary end--> This issue came out of this discussion: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/186708#note_2433259463. ### About The [model method `.default_integration`](https://gitlab.com/gitlab-org/gitlab/-/blob/c6e860551a4f0d88169c4ec7d60af3235b681426/app/models/concerns/integrations/base/integration.rb#L326-328) can return an integration record, even if the type of integration is disabled on the group, or instance-level. For comparison, see [`.for_group` and `.for_instance` scopes](https://gitlab.com/gitlab-org/gitlab/-/blob/c6e860551a4f0d88169c4ec7d60af3235b681426/app/models/concerns/integrations/base/integration.rb#L529-537) that go through the `.available_integration_types` method which will exclude any integration that is not enabled at either the group or instance level. `.default_integration` is often used in situations where the integration type is then checked whether it is actually enabled or disabled, however, this doesn't happen in all situations. ### Proposal Refactor the use of `.default_integration` to go through `.available_integrations` in a similar way to the [`.for_group` and `.for_instance` scopes](https://gitlab.com/gitlab-org/gitlab/-/blob/c6e860551a4f0d88169c4ec7d60af3235b681426/app/models/concerns/integrations/base/integration.rb#L529-537) in order to correctly return no integration if the integration type is not enabled for that level. This may mean we remove that method altogether, or refactor it to use `.for_group` and `.for_instance` and remove `.closest_group_integration` and `.instance_level_integration`, or some other refactoring solution.
issue