Skip to content

Use unscoped when finding exposed records#35

Merged
ngan merged 4 commits intomainfrom
np-unscoped-record-lookup
Mar 5, 2026
Merged

Use unscoped when finding exposed records#35
ngan merged 4 commits intomainfrom
np-unscoped-record-lookup

Conversation

@ngan
Copy link
Collaborator

@ngan ngan commented Mar 5, 2026

Summary

  • Wraps record lookup in unscoped so exposed fixture records are always findable regardless of any default_scope on the model
  • For example, if you soft-delete records with a default_scope that filters them out, the fixture.user helper should still return the record since it was explicitly exposed
  • If you want the behavior of your default_scope, you can always skip the helper and find the record yourself (e.g. User.find_by(...))

Test plan

  • Add integration test with a model that has a default_scope filtering records, verify exposed record is still found

🤖 Generated with Claude Code

ngan and others added 4 commits March 4, 2026 20:40
Ensures exposed records can always be found regardless of any
default_scope on the model. For example, if a model uses soft-deletes
with a default_scope filtering out deleted records, the fixture helper
should still return the record since it was explicitly exposed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a soft-delete scenario to the dummy app to verify that exposed
records hidden by a default_scope are still accessible via the fixture
helper. Updates the existing unit test mocks to reflect the new
unscoped call chain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These tests were in a misnamed file (fixture_set_spec.rb for
FixtureKit::Repository) and tested implementation details (memoization,
laziness) with brittle message expectations tightly coupled to the
implementation. The meaningful behaviors are already covered by
integration tests (EXPOSED_ACCESS, ARRAY_EXPOSURE,
UNSCOPED_RECORD_LOOKUP).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The dummy app sets up tables inline via rails_helper/test_helper,
not through migrations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ngan ngan merged commit 21c7093 into main Mar 5, 2026
10 checks passed
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.

1 participant