Group push rules: stop updating push_rules table
Implementation plan
We should stop updating the push_rules table when defined per group. Now, we should start updating the new group_push_rules table. For this purpose, we should apply the following changes:
- In ee/app/controllers/groups/push_rules_controller.rb we should replace
PushRules::CreateOrUpdateServiceby a new serviceGroupPushRules::CreateOrUpdateService. - In ee/lib/api/group_push_rule.rb we should replace
PushRules::CreateOrUpdateServiceby the new serviceGroupPushRules::CreateOrUpdateService. - In the new service, use something like the following (adapt it as needed) to replicate
PushRules::CreateOrUpdateServicelogic:
# frozen_string_literal: true
module GroupPushRules
class CreateOrUpdateService < BaseContainerService
def execute
group_push_rule = container.group_push_rule || container.build_group_push_rule
if push_rule.update(params)
::Repositories::GroupPushRulesChangesAuditor.new(current_user, push_rule).execute
ServiceResponse.success(payload: { group_push_rule: group_push_rule })
else
error_message = group_push_rule.errors.full_messages.to_sentence
ServiceResponse.error(message: error_message, payload: { group_push_rule: group_push_rule })
end
end
end
end
- Using a new FF (i.e
update_group_push_rules) control the usage of the new service in ee/lib/api/group_push_rule.rb and ee/app/controllers/groups/push_rules_controller.rb.
Expectations
- The output of
Groups::PushRulesController#updateshould remain the same. We are changing the underlying logic to populate thegroup_push_ruletable. - Introduce a new FF (i.e
update_group_push_rules) to control the usage of the newGroupPushRules::CreateOrUpdateServiceservice. If the FF is off then we should continue using the old implementation. Suggestion in #500481 (comment 2445218459). - Create the rollout and cleanup issues for the new FF (
update_group_push_rules). - Provide enough tests to cover the new implementation and ensure there are no regressions introduced when the FF is off.
Edited by 🤖 GitLab Bot 🤖