Skip to content

Commit

Permalink
fixup! Use tidy-html5 to validate the term-table page
Browse files Browse the repository at this point in the history
  • Loading branch information
octopusinvitro committed Sep 27, 2016
1 parent 9077149 commit 3df7f00
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
43 changes: 43 additions & 0 deletions t/web/term_table/bahamas.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true
require 'test_helper'
require_relative '../../../app'

describe 'Bahamas' do
subject { Nokogiri::HTML(last_response.body) }
let(:hubert) { subject.css('#mem-4a7bfd46-3b03-46ec-957f-3ef526b04bbe') }
let(:damian) { subject.css('#mem-58709524-7f66-44fd-8315-9712c4655768') }
let(:philip) { subject.css('#mem-dcd1a356-a7e6-409b-8028-27fea2691105') }

before do
stub_popolo('4da60b8', 'Bahamas/House_of_Assembly')
get '/bahamas/house-of-assembly/term-table/2012.html'
end

describe 'alt attribute on avatars' do
it 'has the person name in a normal image' do
img = hubert.css('img.person-card__image')[0]
img.attr('alt').must_equal 'Member headshot for Hubert Chipman'
end

it 'has the person name in a normal image when JS is disabled' do
img = hubert.css('img.person-card__image')[1]
img.attr('alt').must_equal 'Member headshot for Hubert Chipman'
end

it 'has the person name in a placeholder image' do
img = damian.css('img.person-card__image')
img.attr('alt').text.must_equal 'Placeholder image for Damian Gomez'
end

it 'doesnt break for names with double quotes' do
img = philip.css('img.person-card__image')[0]
img.attr('alt').must_equal 'Member headshot for Philip "Brave" Davis'
end
end

describe 'HTML validation' do
it 'has no errors in the term-table page' do
last_response_must_be_valid
end
end
end
38 changes: 0 additions & 38 deletions t/web/term_table/phillipines.rb

This file was deleted.

8 changes: 4 additions & 4 deletions views/term_table.erb
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@
data-src="<%= person.proxy_image %>"
style="display: none"
class="person-card__image"
alt="Member headshot for <%= h person.name %>">
alt="Member headshot for <%= escape_html(person.name) %>">
<noscript><img src="<%= person.proxy_image %>" class="person-card__image"
alt="Member headshot for <%= h person.name %>"></noscript>
alt="Member headshot for <%= escape_html(person.name) %>"></noscript>
<% else %>
<img src="/images/person-placeholder-108px.png" class="person-card__image"
alt="Placeholder image for <%= h person.name %>">
alt="Placeholder image for <%= escape_html(person.name) %>">
<% end %>

<h3 class="person-card__name"><%= person.name %></h3>
Expand Down Expand Up @@ -198,7 +198,7 @@
<div class="page-section page-section--grey source-credits">
<div class="container">
<% if @page.data_sources %>
<p>Main Source<% if @page.data_sources.size > 1 %>s<% end %>: <%= @page.data_sources.map { |url| %Q(<a href="#{url}">#{url}</a>) }.join(", ") %></p>
<p>Main Source<% if @page.data_sources.size > 1 %>s<% end %>: <%= @page.data_sources.map { |url| %Q(<a href="#{escape_uri(url)}">#{url}</a>) }.join(", ") %></p>
<% end %>
<p><b>Anything wrong?</b> If you've spotted an error, or the data is incomplete,
here's <a href="http://docs.everypolitician.org/contribute.html">how to get that fixed</a>.</p>
Expand Down

0 comments on commit 3df7f00

Please sign in to comment.