Skip to content

Draft: Skip callback in a subclass

Peter Leitzen requested to merge pl-inherit-to-skip-callback into master

What does this MR do?

An alternative approach to solve !42238 (merged) which contributes to #247865.

Instead of calling MergeRequest.skip_callback we create a subclass and skip the callback which only affects the subclass; not the parent:

class MergeRequestWithoutMergeRequestDiff < MergeRequest
  skip_callback(:create, :after, :ensure_merge_request_diff)
end

MergeRequest.__callbacks[:create].to_a.map(&:filter).grep(/ensure_merge_request_diff/)
# => [:ensure_merge_request_diff]

MergeRequestWithoutMergeRequestDiff.__callbacks[:create].to_a.map(&:filter).grep(/ensure_merge_request_diff/)
# => []

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen

Merge request reports