Move `prepend` calls outside of classes to the last line in the file
In !8153 (merged)/ and !8047 (merged) 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 !8153 (comment 113239380), and I believe we should start applying this to all existing cases to ensure the codebase is consistently using this pattern.
app/controllers: !8201 (merged)
app/finders: !8192 (merged)
app/mailers: !8202 (merged)
app/models: !8198 (merged)
app/policies: !8204 (merged)
app/presenters: !8205 (merged)
app/services: !8200 (merged)
app/workers: !8206 (merged)
app/helpers: !8422 (merged)
- Remainder: !8424 (merged)
To do this, you can use the following script: gitlab-org/release/framework$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