Repository navigation
Make fixture tests own their models - #117
Conversation
e3fb8ad to
5d1b1ec
Compare
5d1b1ec to
5390578
Compare
1dd45e3 to
3906817
Compare
3906817 to
4a17885
Compare
e345da3 to
a4cca8d
Compare
a4cca8d to
f68e047
Compare
f68e047 to
019ab2d
Compare
019ab2d to
0b43dcb
Compare
0b43dcb to
ef7528f
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The namer test can reuse a stale Rails fixture cache after shared database setup is removed.
1 open finding
What changed in this PR
Migrates model-backed tests to class-owned ephemeral schemas and removes shared database setup.
Changes:
- Adds inline
with_modelschemas and isolated fixture storage. - Separates metadata-aware and conventional legacy fixture coverage.
- Removes shared fixed-schema support and updates migration documentation.
| File | Description |
|---|---|
test/test_helper.rb |
Removes shared schema helpers and simplifies fixture generation. |
test/support/test_database.rb |
Deletes shared fixed-schema support. |
test/namer_test.rb |
Adds an owned ephemeral model schema. |
test/model_resolver/ambiguous_model_error_test.rb |
Clarifies the test class name. |
test/legacy_fixtures/magical_creatures.yml |
Adds Rails model metadata. |
test/legacy_fixtures/conventional_legacy_creatures.yml |
Adds metadata-free legacy input. |
test/legacy_fixture_mode/conventional_model_metadata_test.rb |
Tests regeneration of conventional fixtures with metadata. |
test/legacy_fixture_mode_test.rb |
Migrates legacy loading tests to an ephemeral model. |
test/legacy_fixture_mode_fixture_generation_test.rb |
Migrates generation tests to isolated fixtures and models. |
test/fixture_builder_test.rb |
Gives integration tests an owned model schema. |
test/configuration/manifest_test.rb |
Gives manifest tests an owned model schema. |
test/configuration/generated_file_marker_test.rb |
Replaces manual tables with with_model. |
test/builder/serialization_test.rb |
Gives serialization tests an owned model schema. |
test/builder/generated_fixture_ownership_test.rb |
Replaces manual ownership tables with ephemeral models. |
doc/plans/2026-08-29-maintainer-backlog-triage.md |
Marks the migration stack complete. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fixture_sets = ActiveRecord::FixtureSet.create_fixtures( | ||
| test_path("legacy_fixtures"), | ||
| MagicalCreature.table_name | ||
| "magical_creatures" |
There was a problem hiding this comment.
Fixed in 07e4e53. The test now calls ActiveRecord::FixtureSet.reset_cache before loading, and asserts the returned fixture set belongs to the current MagicalCreature. Running the legacy-mode tests first in the same process reproduced the stale set without the reset; the test only passed because both ephemeral models get the same with_model table name within one process.
03e6fb0 to
3619e36
Compare
3619e36 to
2853b86
Compare
2853b86 to
1d5d7dc
Compare
07e4e53 to
f9a6c3d
Compare
f9a6c3d to
9f37e00
Compare
9f37e00 to
a67f5f5
Compare

The model-aware fixture foundation is now able to generate Rails-native metadata for ephemeral model tables, but the remaining ordinary test cases still rely on globally managed fixed schemas. That coupling makes test ownership and fixture cleanup less clear.
This migration moves each ordinary model-backed test case to an inline
with_modelschema owned by its Test::Unit class, including the integration, manifest, and serialization cases in the new test hierarchy. It keeps the intentional manual boundaries for raw SQL, autoload timing, alternate connection pools, schema errors, namespaced constants, subprocesses, and STI.The legacy suite now covers both metadata-aware loading for ephemeral model tables and metadata-free loading for a conventional checked-in fixture. Shared fixed-schema support is removed after its final consumer migrates.
This is the dependent migration for #116.
Removing the shared fixed-schema support also removes the per-test reconnect to an in-memory SQLite database, which Rails main now reuses instead of replacing.
It also trues up the docs now that #116 has merged. The maintainer plan records #49, #72 (for tables with a primary key), #109, #119 and #129 as resolved, and notes the remaining keyless-table ordering gap. The README no longer advises against namespaced models.
Refs #124 (closed by #116)