From 0c650e05a596f0cbf72ae92d09186cbd5ff3ff12 Mon Sep 17 00:00:00 2001 From: Spencer Dixon Date: Fri, 29 Nov 2024 11:07:29 +0000 Subject: [PATCH] Moved manual pages to a constant --- lib/page_modification_tracker.rb | 16 +++++++--------- spec/lib/page_modification_tracker_spec.rb | 4 +--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/page_modification_tracker.rb b/lib/page_modification_tracker.rb index 25b15d4e7e..0720857d0a 100644 --- a/lib/page_modification_tracker.rb +++ b/lib/page_modification_tracker.rb @@ -2,6 +2,12 @@ require "digest/sha1" class PageModificationTracker + MANUAL_PAGES = { + "/events/about-get-into-teaching-events" => {}, + "/events" => {}, + "/mailinglist/signup/name" => {}, + } + attr_reader :app, :headers def initialize(host: "localhost:3000", selector: "body") @@ -41,14 +47,6 @@ def track_page_modifications private - def manual_pages - { - "/events/about-get-into-teaching-events" => {}, - "/events" => {}, - "/mailinglist/signup/name" => {}, - } - end - def published_pages events = GetIntoTeachingApiClient::TeachingEventsApi.new.search_teaching_events( start_after: Time.zone.now, @@ -57,7 +55,7 @@ def published_pages ) content_pages = ::Pages::Frontmatter.list.reject { |_path, fm| fm[:draft] } event_pages = events.map { |e| Rails.application.routes.url_helpers.event_path(e.readable_id) }.index_with({}) - content_pages.merge(**event_pages, **manual_pages) + content_pages.merge(**event_pages, **MANUAL_PAGES) end def request_path(path, app, headers) diff --git a/spec/lib/page_modification_tracker_spec.rb b/spec/lib/page_modification_tracker_spec.rb index 15a39bf391..5cb722c0b7 100644 --- a/spec/lib/page_modification_tracker_spec.rb +++ b/spec/lib/page_modification_tracker_spec.rb @@ -29,9 +29,7 @@ .to receive(:search_teaching_events) .and_return([]) - allow_any_instance_of(described_class) - .to receive(:manual_pages) - .and_return({}) + stub_const("PageModificationTracker::MANUAL_PAGES", {}) allow(::Pages::Frontmatter) .to receive(:list)