Skip to content

Add shared author_creditable tests for all AuthorCreditable models#1325

Merged
maebeale merged 1 commit intomainfrom
maebeale/author-name-display-tests
Mar 4, 2026
Merged

Add shared author_creditable tests for all AuthorCreditable models#1325
maebeale merged 1 commit intomainfrom
maebeale/author-name-display-tests

Conversation

@maebeale
Copy link
Collaborator

@maebeale maebeale commented Mar 3, 2026

What is the goal of this PR and why is this important?

  • The AuthorCreditable concern (#author_credit) formats author names based on preference (full name, first name + last initial, first name only, last name only, anonymous)
  • Only 2 of 6 models using this concern had tests, and those were missing coverage for first_name_last_initial and last_name_only preferences
  • This PR ensures all name display preferences are tested across every model that uses the concern

How did you approach the change?

  • Created a shared example (spec/support/shared_examples/author_creditable.rb) following the existing featureable and mentioner shared example patterns
  • Tests all 7 scenarios: full_name, first_name_last_initial, first_name_only, last_name_only, anonymous, nil fallback, and no-person fallback
  • Automatically skips the nil fallback test for models that validate presence of author_credit_preference (StoryIdea, WorkshopVariationIdea)
  • Replaced inline tests in Story and Workshop specs with the shared example
  • Added shared example to StoryIdea, WorkshopIdea, WorkshopVariation specs
  • Created new spec file for WorkshopVariationIdea

Anything else to add?

  • 141 examples, 0 failures across all 7 affected spec files
  • Net effect: -71 lines of duplicated tests, +69 lines of shared + comprehensive coverage

🤖 Generated with Claude Code

@maebeale maebeale requested a review from jmilljr24 March 4, 2026 00:33
Story and Workshop had partial #author_credit coverage (missing
first_name_last_initial and last_name_only). StoryIdea, WorkshopIdea,
WorkshopVariation, and WorkshopVariationIdea had none. Extract a shared
example that tests all preference values and include it everywhere.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/author-name-display-tests branch from 27a461c to da07f76 Compare March 4, 2026 12:42
@maebeale maebeale merged commit 81ccafe into main Mar 4, 2026
3 checks passed
@maebeale maebeale deleted the maebeale/author-name-display-tests branch March 4, 2026 12:50
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