Skip to content

Make fixture tests own their models - #117

Merged
nertzy merged 1 commit into
masterfrom
ephemeral-fixture-test-ownership
Oct 13, 2026
Merged

nertzy merged 1 commit into
masterfrom
ephemeral-fixture-test-ownership

Conversation

@nertzy

@nertzy nertzy commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

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_model schema 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)

@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from e3fb8ad to 5d1b1ec Compare September 8, 2026 00:18
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 5d1b1ec to 5390578 Compare September 8, 2026 00:44
@nertzy
nertzy marked this pull request as ready for review September 8, 2026 16:23
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch 2 times, most recently from 1dd45e3 to 3906817 Compare September 8, 2026 20:35
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 3906817 to 4a17885 Compare September 8, 2026 20:51
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch 2 times, most recently from e345da3 to a4cca8d Compare September 11, 2026 22:19
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from a4cca8d to f68e047 Compare September 11, 2026 23:25
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from f68e047 to 019ab2d Compare September 12, 2026 00:17
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 019ab2d to 0b43dcb Compare September 12, 2026 23:44
Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:32
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 0b43dcb to ef7528f Compare October 12, 2026 17:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_model schemas 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.

Comment thread test/namer_test.rb
Comment on lines 84 to +86
fixture_sets = ActiveRecord::FixtureSet.create_fixtures(
test_path("legacy_fixtures"),
MagicalCreature.table_name
"magical_creatures"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch 2 times, most recently from 03e6fb0 to 3619e36 Compare October 12, 2026 18:10
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 3619e36 to 2853b86 Compare October 12, 2026 18:35
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 2853b86 to 1d5d7dc Compare October 12, 2026 23:17
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch 2 times, most recently from 07e4e53 to f9a6c3d Compare October 13, 2026 22:17
Base automatically changed from model-aware-fixture-generation to master October 13, 2026 22:24
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from f9a6c3d to 9f37e00 Compare October 13, 2026 22:24
@nertzy
nertzy force-pushed the ephemeral-fixture-test-ownership branch from 9f37e00 to a67f5f5 Compare October 13, 2026 22:26
@nertzy
nertzy merged commit f5502d7 into master Oct 13, 2026
10 checks passed
@nertzy
nertzy deleted the ephemeral-fixture-test-ownership branch October 13, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants