Skip to content

Add rubocop cop to prevent model usage in migration specs#5066

Open
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:rubocop-no-model-in-migration-specs
Open

Add rubocop cop to prevent model usage in migration specs#5066
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:rubocop-no-model-in-migration-specs

Conversation

@philippthun
Copy link
Copy Markdown
Member

@philippthun philippthun commented Apr 28, 2026

Migration specs roll back the schema before running, so model classes may reference columns that don't exist yet. Using raw Sequel operations ensures specs are independent of the current model code, as documented in spec/migrations/Readme.md.

  • Add Migration/NoModelInSpecs cop that flags any method call on a *Model constant receiver in spec/migrations/
  • Replace model .make calls with raw db[:table].insert in four migration specs: sidecars, revision_sidecars, sidecar_process_types, and revision_process_commands
  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@philippthun philippthun force-pushed the rubocop-no-model-in-migration-specs branch from bc8b308 to 50f753e Compare April 28, 2026 10:20
Migration specs roll back the schema before running, so model classes
may reference columns that don't exist yet. Using raw Sequel operations
ensures specs are independent of the current model code, as documented
in spec/migrations/Readme.md.

- Add Migration/NoModelInSpecs cop that flags any method call on a
  *Model constant receiver in spec/migrations/
- Replace model .make calls with raw db[:table].insert in four
  migration specs: sidecars, revision_sidecars, sidecar_process_types,
  and revision_process_commands
@philippthun philippthun force-pushed the rubocop-no-model-in-migration-specs branch from 50f753e to e0acf56 Compare April 28, 2026 11:12
@philippthun philippthun marked this pull request as ready for review April 28, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant