Skip to content

Commit

Permalink
Add unpublished posts to the scraper page to have their previews
Browse files Browse the repository at this point in the history
  • Loading branch information
octopusinvitro committed Apr 20, 2017
1 parent 543ea5a commit 8aa9a73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,7 @@
get '/scraper-start-page.html' do
@people = representatives.find_all + senators.find_all + governors.find_all
@places = mapit.places_of_type('FED') + mapit.places_of_type('SEN') + mapit.places_of_type('STA')
finder = Document::Finder.new(pattern: posts_pattern, baseurl: '/blog/')
@posts = finder.find_unpublished
erb :scraper_start_page, layout: false
end
10 changes: 10 additions & 0 deletions tests/web/unlinked_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
subject.xpath('//a[contains(@href, "/people/")]').count.must_equal(fed + sen + sta)
subject.xpath('//a[contains(@href, "/places/")]').count.must_equal(fed + sen + sta)
end

it 'scrapes unlinked post pages' do
unpublished = '---
published: false
---'
Dir.stub :glob, [new_tempfile(unpublished)] do
get '/scraper-start-page.html'
refute_empty(subject.xpath('//a[contains(text(), "Unlinked post")]'))
end
end
end

describe 'The Jinja2 Template' do
Expand Down
4 changes: 4 additions & 0 deletions views/scraper_start_page.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
<p><a href="<%= place.url %>people/">Old people page route, must trigger redirect to <%= place.url %></a></p>
<p><a href="<%= place.url %>places/">Old places page route, must trigger redirect to <%= place.url %></a></p>
<% end %>

<% @posts.each do |post| %>
<p><a href="<%= post.url %>">Unlinked post - <%= post.title %></a></p>
<% end %>

0 comments on commit 8aa9a73

Please sign in to comment.