Back to Source Monitor

SourceDetailsPresenter Extraction

.vbw-planning/milestones/07-rails-audit-and-refactoring/05-view-layer-extraction/01-SUMMARY.md

0.13.01.8 KB
Original Source

What Was Built

  • BasePresenter (SimpleDelegator) base class with ActionView number/date/text helpers
  • SourceDetailsPresenter wrapping Source model with formatted display methods: fetch_interval_display, circuit_state_label, adaptive_interval_label, details_hash, formatted_next_fetch_at, formatted_last_fetched_at
  • Updated _details.html.erb to use presenter instead of ~30 lines of inline hash building and formatting logic
  • 23 unit tests covering all presenter methods including delegation, nil handling, and conditional formatting

Commits

  • 7c2604b feat(05-01): extract SourceDetailsPresenter from _details.html.erb

Tasks Completed

  1. Created BasePresenter and wrote 23 SourceDetailsPresenter tests (TDD red)
  2. Implemented SourceDetailsPresenter with all required methods (TDD green)
  3. Updated _details.html.erb to instantiate presenter and use details_hash
  4. Verified: presenter tests pass, controller tests pass, full suite (1522 tests) pass, RuboCop zero offenses on new files

Files Modified

  • app/presenters/source_monitor/base_presenter.rb (new) -- SimpleDelegator base class
  • app/presenters/source_monitor/source_details_presenter.rb (new) -- presenter with formatting methods
  • test/presenters/source_monitor/source_details_presenter_test.rb (new) -- 23 tests
  • app/views/source_monitor/sources/_details.html.erb (modified) -- replaced inline logic with presenter calls

Deviations

  • Website row kept in template (not in details_hash) because it requires the external_link_to view helper which is not available in the presenter without view_context. This is a minor scope adjustment (DEVN-01) that preserves identical rendered output.
  • 48 pre-existing RuboCop offenses detected (DEVN-05) -- all in unmodified files, zero offenses in new presenter files.