Skip to content

Commit

Permalink
Moved manual pages to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerldixon committed Nov 29, 2024
1 parent 6f17cf5 commit 0c650e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 7 additions & 9 deletions lib/page_modification_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions spec/lib/page_modification_tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0c650e0

Please sign in to comment.