Skip to content

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

Merged
philippthun merged 1 commit into
cloudfoundry:mainfrom
sap-contributions:rubocop-no-model-in-migration-specs
May 19, 2026
Merged

Add rubocop cop to prevent model usage in migration specs#5066
philippthun merged 1 commit into
cloudfoundry: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 2 times, most recently 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
@philippthun philippthun force-pushed the rubocop-no-model-in-migration-specs branch from e0acf56 to bfe8c24 Compare May 18, 2026 10:33
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 bfe8c24 to 7ff74b6 Compare May 18, 2026 10:41
@philippthun philippthun merged commit ff78b82 into cloudfoundry:main May 19, 2026
11 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request May 19, 2026
Changes in cloud_controller_ng:

- Use have_queried_db_times matcher in lifecycle ordering tests
    PR: cloudfoundry/cloud_controller_ng#5095
    Author: Philipp Thun <philipp.thun@sap.com>

- Fix two flaky test failures caused by test isolation issues
    PR: cloudfoundry/cloud_controller_ng#5084
    Author: Philipp Thun <philipp.thun@sap.com>

- Document case sensitivity of name fields in API docs
    PR: cloudfoundry/cloud_controller_ng#5079
    Author: Philipp Thun <philipp.thun@sap.com>

- Add rubocop cop to prevent model usage in migration specs
    PR: cloudfoundry/cloud_controller_ng#5066
    Author: Philipp Thun <philipp.thun@sap.com>

Dependency updates in cloud_controller_ng:

- build(deps-dev): bump mock_redis from 0.53.0 to 0.54.0
    PR: cloudfoundry/cloud_controller_ng#5106
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

- build(deps): bump zeitwerk from 2.7.5 to 2.8.0
    PR: cloudfoundry/cloud_controller_ng#5107
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

- build(deps): bump oj from 3.17.0 to 3.17.1
    PR: cloudfoundry/cloud_controller_ng#5108
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

- build(deps-dev): bump solargraph from 0.59.0 to 0.59.1
    PR: cloudfoundry/cloud_controller_ng#5109
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

2 participants