Move `prepend` calls outside of classes to the last line in the file
In https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8153/ and https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8047 we moved the
prepend line of the affected models to the last line, outside of the
class block. This was necessary to ensure all code was defined that the prepended modules may want to override, as otherwise various specs would fail.
This approach has two main benefits:
- When we prepend the module, the target class has been fully defined, instead of only partially. This means we don't have to place the
prependin a specific place if we want to depend on say constants in the class.
- It reduces the chance of merge conflicts, because the
prependnow comes after all the CE code
This was discussed in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8153#note_113239380, and I believe we should start applying this to all existing cases to ensure the codebase is consistently using this pattern.
- Remainder: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8424
To do this, you can use the following script: https://gitlab.com/gitlab-org/release/framework/snippets/1773219
Dir['app/models/**/*.rb'].each do |path|to use the appropriate path (e.g.
- Run it using
ruby move_prepend.rbin the EE source directory