Skip to content

v2.0.0: Rails conventions refactor#38

Merged
vishaltps merged 7 commits into
mainfrom
feature/rails-conventions-v2
May 13, 2026
Merged

v2.0.0: Rails conventions refactor#38
vishaltps merged 7 commits into
mainfrom
feature/rails-conventions-v2

Conversation

@vishaltps
Copy link
Copy Markdown
Owner

Summary

Major architectural refactor: replaces the gem's HTML-in-Ruby rendering pipeline (13 *Presenter classes + HtmlGenerator + StylesheetGenerator emitting heredoc HTML) with standard Rails ERB views, helpers, and partials. CSS and JavaScript are now served as external assets via a controller-based pipeline with content-hashed URLs and Cache-Control: immutable. Public API (config, mount, URLs, auth, CSP) is unchanged.

Why

  • Contributor friction: ERB tooling didn't apply to heredoc-HTML; simple UI tweaks required jumping between presenter Ruby files
  • Performance: heredoc string interpolation ran on every request; ERB is compiled and cached
  • CSP friction: every dashboard page emitted ~2,000 lines of inline <style nonce> + several inline <script nonce> blocks, requiring host-app nonce configuration to work under strict CSP

Result

v1.3.x v2.0
Inline <style nonce> blocks per page 1 (~2,000 lines) 0
Inline <script nonce> blocks per page 4-5 0
Strict CSP script-src 'self'; style-src 'self' works no yes
Browser asset caching per-request render Cache-Control: immutable, memory/disk cache
ERB tooling on dashboard files no yes
Codebase shape non-standard presenters standard Rails (views/, helpers/, assets/)

Net LOC: ~5,000 lines of HTML-in-Ruby removed; ~800 lines of ERB + helpers + one 2,000-line application.css + one application.js added.

Breaking changes (internal only)

The following internal classes are removed. None were documented as public API:

  • SolidQueueMonitor::HtmlGenerator, StylesheetGenerator, ChartPresenter, BasePresenter
  • All *Presenter classes
  • BaseController#render_page

Users who reached into these via monkey-patches will need to migrate to view/helper overrides. CHANGELOG documents the upgrade path.

Compatibility

  • Rails: >= 7.0 (unchanged)
  • Solid Queue: >= 0.1.0 (unchanged)
  • API-only host apps: still supported — no Sprockets / Propshaft dependency added
  • Strict CSP: now works out of the box (was: required nonce config in v1.x)

Test plan

  • Full RSpec suite green (294 examples, 0 failures, stable across multiple random seeds)
  • Rubocop clean (68 files, no offenses)
  • Manually verified in a host app: all dashboard pages render, light/dark theme switches work, auto-refresh + chart tooltips + bulk actions work, assets serve with Cache-Control: immutable, dark-theme paused queue row readable
  • Verified under strict script-src 'self'; style-src 'self' CSP (no nonces) in a separate test app — zero CSP violations

vishaltps added 7 commits May 12, 2026 15:19
Replaces 11 *Presenter classes with app/views/**.html.erb plus
app/helpers/solid_queue_monitor/* helpers. Serves CSS/JS via a new
AssetsController with content-hashed URLs, removing the need for
inline <style nonce>/<script nonce> blocks. Public API unchanged
(config block, mount, URLs, auth, CSP nonce support).

WIP: jobs#show specs failing with MissingExactTemplate despite the
template existing — diagnosis + Phase 6 cleanup + version bump still
pending in follow-up commits.
- Delete BasePresenter, StatsPresenter, HtmlGenerator, StylesheetGenerator
  (~2,750 LOC of legacy HTML-in-Ruby removed)
- Remove BaseController#render_page (replaced by Rails implicit rendering)
- Upgrade CSP spec with no-inline-style-block / no-inline-script-block assertions
- Bump VERSION to 2.0.0
- Add CHANGELOG entry for [2.0.0] - 2026-05-12
- Refine job_details + jobs helpers and 3 job partials
The .queue-paused row only set a light cream background (#fffbeb)
without an explicit text color, so the dark theme inherited the
near-white default text and rendered as nearly invisible. Adds a
dark-theme override with dark amber background + light amber text
(~11:1 contrast). Light theme unchanged.
Reflects v2.0 behavior: strict `script-src 'self'; style-src 'self'`
works out of the box now that CSS/JS are served as external assets.
Removes the v1.3.0 caveat about nonces being required for strict
policies, and adds an upgrade note for v1.x users.
These four index-only controllers lacked dedicated request specs in v1.x.
The refactor inherited the gap. Each new spec covers: happy path, empty
state, key DOM elements, filter by class_name (and queue_name for
ready_jobs).

Brings spec total from 294 to 315 examples.
@vishaltps vishaltps merged commit fbb65cb into main May 13, 2026
3 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