test(activestorage): prove association targets through attachments - #16
Merged
Conversation
- test-only dependency, like actionpack/railties: needed by the integration spec proving association targets traverse attachments
- boots the real engine in a minimal Rails::Application, in the
integration spec file only — spec_helper and the rest of the suite
stay engine-free
- has_one_attached / has_many_attached generate concrete associations
from the owner's side, so the ordinary declared paths apply:
`{ document_blob: :content_type }`, `{ document_attachment:
:created_at }`, DISTINCT through has_many_attached, declarations
validator green against the generated associations
- the boot re-establishes the database connection, so the business
schema moves to spec/support/schema.rb and is rebuilt after boot;
DATABASE_URL is pinned to sqlite3 in-memory so a developer's local
environment cannot leak into the suite
- rubocop: spec support code excluded from AbcSize/MethodLength —
schema definitions are declarative, their length tracks the number
of tables, not complexity; lib/ stays fully covered
🛡️ Coverage Report: 100.0% (0.0%)
✅ All changes are tested. |
🛡️ RuboCop: 0 offenses (0)
✅ No RuboCop offenses. |
🛡️ Documentation Quality: 100.0% (0.0%)
✅ Documentation quality above threshold. |
📊 Code Quality Report
✅ No new code-quality findings. 🔍 All 59 reek smells on this PR
📊 Flog complexity breakdown📊 Flay duplication breakdown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI guarantee for the ActiveStorage question raised after #15: the associations
has_one_attached/has_many_attachedgenerate are concrete from the owner's side, so the declared association paths traverse them with no polymorphic hop — now proven by an integration spec booting the real engine.Changes
spec/active_storage_spec.rb: boots a minimalRails::Applicationwith the real ActiveStorage engine (in that file only — the rest of the suite stays engine-free) and proves: equality on{ document_blob: :content_type }, date bounds on{ document_attachment: :created_at },DISTINCTthroughhas_many_attached, records without attachment dropped, declarations validator green against the generated associationsspec/support/schema.rband is rebuilt after boot;DATABASE_URLis pinned to sqlite3 in-memory so a developer's local environment (a PostgresDATABASE_URL, typically) cannot leak into the suiteactivestorageadded to the Gemfile as a test-harness-only dependency, next to actionpack/railties; runtime deps unchanged (still activerecord + activesupport only)Metrics/AbcSize/MethodLength(declarative schema definitions), justified in the config;lib/stays fully covered152 examples, 0 failures, 100% line coverage.