Clean generated migrations and future-proof coverage - #25
Conversation
|
Cross-repo counterpart: https://github.com/railsfast/railsfast-base/pull/108. RailsFast #108 upstreams the reusable clean-runner credential handling, libvips package, sanitizer advisory fixes, and requested Claude auto-review removal. It deliberately does not install api_keys because RailsFast Base contains only a commented opt-in dependency. |
Final ruleset/merge decisionThe PR's original SSH-signature handoff note is superseded by this comment. The head commit did contain an SSH signature, but GitHub reported Per the repository owner's explicit decision that mandatory signed commits were too strict here, ruleset The active ruleset still enforces:
After that narrowly scoped settings change, GitHub reported the PR This is an intentional maintainability/security tradeoff, not an unrecorded missing task. Commit signatures remain welcome, but they are no longer a repository availability gate. |
Post-merge main verificationMerged as Every workflow on that exact
No immediate v0.4.1 release is warranted: this PR changes future generator output and test tooling only. It does not repair a shipped v0.4.0 runtime or schema defect. The changes are recorded under |
Context
This is a follow-up to the adversarial v0.4.0 hardening and downstream adoption work recorded in #23 and issue #12. While applying v0.4.0 to real RailsFast applications, we audited whether any downstream discovery belonged in the gem itself rather than being left as application-local knowledge.
This PR contains the one gem-level generator-quality finding from that pass and a test-infrastructure compatibility issue exposed while validating it. It does not alter authentication, authorization, key material, persistence, cache, migration schema, or any v0.4.0 runtime security control.
Findings and fixes
Generated migrations contained dead generator helpers
Both
create_api_keys_table.rb.erbandadd_authentication_index_to_api_keys.rb.erbcorrectly interpolatemigration_versionwhile the Rails generator renders the ERB superclass. They also emitted a secondmigration_versioninstance method into the generated migration.That emitted method was unreachable: Active Record has already parsed the rendered superclass version before a migration instance exists, and no generated migration code calls the method. It was harmless, but it gave every new installation and every v0.4.0 authentication-index upgrade misleading dead code to own forever.
This PR removes the emitted methods while retaining the generator-side helpers that perform the actual ERB interpolation. Regression assertions now prove neither generated migration contains
def migration_version.Existing generated migrations remain valid and require no edit, rollback, rerun, data change, key rotation, or production deployment. This is output hygiene for future generator runs.
SimpleCov was using APIs scheduled for removal
The focused generator test passed its assertions, but SimpleCov warned that:
SimpleCov.startfrom.simplecovwill stop being supported;add_filteris deprecated in favor ofskip;track_filesis deprecated in favor ofcover.Coverage configuration now remains in
.simplecov, startup/reporting happens intest/test_helper.rbbefore application code loads, and the currentskip/coverAPIs preserve the existing enforced 80% line / 75% branch floors.The apparent non-zero result from an isolated test-file run was only the repository-wide coverage gate doing its job: one generator file cannot cover the whole gem. The canonical full suite is the authoritative validation and passes above both floors.
Validation
bundle exec rake test: 315 tests, 970 assertions, 0 failures, 0 errors, 0 skipsgit diff --check: cleanbundle exec rubocopis not a valid project gate. A globally installed RuboCop was intentionally not used as an authority because it applies unrelated defaults, cannot correctly parse ERB migration templates as plain Ruby, and reports pre-existing style choices throughout the test helper.GitHub CI remains the cross-version authority and will exercise Ruby 3.3/3.4/4.0 against Rails 7.2/8.0/8.1, plus the security and CodeQL workflows.
Release and upgrade impact
rails generate api_keys:add_authentication_indexand migrate before deploying v0.4.0, as documented in Release api_keys 0.4.0 security hardening聽#23 and the v0.4.0 release notes.Durable handoff notes
api_keys; it contains only a commented opt-in Gemfile line and commented route, so no base-template dependency pin or API-key migration belongs there.rameerez/licenseseat#45andrameerez/vehiclesdb-web#9; both are merged and their post-merge main CI runs passed.rameerez/vehiclesdbdataset repository does not consume the gem and was not changed.railsfast/railsfast-baseseparately and will be cross-linked after both PRs exist.unknown_keyuntil that public key is registered separately as an account signing key; this is an account metadata issue, not missing commit signature data.Related records