Skip to content

Add admin test coverage and fix two letters-form crashes - #12

Merged
jayvarner merged 12 commits into
mainfrom
develop
Aug 10, 2026
Merged

Add admin test coverage and fix two letters-form crashes#12
jayvarner merged 12 commits into
mainfrom
develop

Conversation

@jayvarner

Copy link
Copy Markdown
Member

Summary

Adds test coverage for the Administrate admin dashboards ahead of the planned administrate 0.20 -> 1.0 upgrade, and fixes two real bugs found while writing it - both were breaking the letters admin form in production.

  • Request specs for all 9 routed admin dashboards (entities, letters, big_sams, media, faqs, about_pages, mentions, repositories, languages) - baseline auth/render coverage plus deep specs for the custom LettersController/EntitiesController logic (date-range filtering, referer-based param restoration, blank-label exclusion, e_type pre-population)
  • Unit specs for the three custom Administrate::Field subclasses (HasManyThroughField, RichTextField's sanitize allowlist, ContenteditableField) and dashboard-level specs (display_resource, LetterDashboard#permitted_attributes)
  • System specs (new Capybara + headless Chrome infra, mirroring Administrate's own test setup) covering the letters form's jQuery/selectize entity-tagging widget - the piece most likely to silently break across the Administrate upgrade, since no request spec executes JS

Bugs fixed

  1. HasManyThroughField#associated_resource_options hardcoded order: { e_type: :asc } in its Elasticsearch query, but e_type was never mapped as sortable - this crashed the letters new/edit page for every letter. Fixed by sorting in Ruby after the search instead of asking Elasticsearch to sort.
  2. The letters form has no visible submit button - saving depends entirely on the JS auto-submit-on-selectize-change behavior, which was crashing on page load (Cannot read properties of null) because of two dead lines referencing an authenticity_token field this api_only app never renders. Removed them; neither variable was ever used afterward.

Known bugs documented, not fixed

10 pre-existing bugs surfaced by the new specs are left as pending/skip with the exact root cause in each - wrong accessible_action? argument order in mentions/edit.html.erb and media/show.html.erb, a flat-vs-nested view-iteration bug in mentions/_form.html.erb, and LetterDashboard::ATTRIBUTE_TYPES missing a :published entry that breaks both show and index pages.

Test plan

  • Full new spec suite green and stable across 10+ random seeds (spec/requests/admin, spec/fields, spec/dashboards, spec/system)
  • Full existing application test suite green with no regressions (315 examples, 0 failures)
  • Confirm the letters admin form actually saves in production after deploy (this is exactly the workflow that was broken)

@jayvarner
jayvarner merged commit 8c43974 into main Aug 10, 2026
1 check 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