Integration.default_integration should be returning nil if integration is not enabled at group, or instance level
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
This issue came out of this discussion: !186708 (comment 2433259463).
About
The model method .default_integration
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 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 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.