Skip to content

Commit 68e33fc

Browse files
authored
Merge pull request #1815 from coderdojo-japan/test/kata-dead-link-check
/kata ページの内部リンク死活チェックテストを追加
2 parents 069dc56 + 170b4c1 commit 68e33fc

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

app/views/docs/kata.html.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<br>
5858
<p>各 Dojo は、チャンピオンやメンターと呼ばれる協力者によって自主的に運営されています。プログラマーやデザイナーだけでなく、学生や教員、アーティストやフリーランス、起業家や投資家などの方々が分野横断的に協力しあって、それぞれの Dojo が継続的に運営されています。もちろん、参加者自身や参加者の親が運営に協力する事例も多いです。</p>
5959
<%= lazy_image_tag('/kata/coderdojo-zero.webp', alt: 'CoderDojo を支える方々の写真', style: 'margin-top: 30px; margin-bottom: 40px;', min: true) %>
60-
60+
6161
<h3 id='welcome'>
6262
<a href='#welcome'></a>
6363
初めての人へ
@@ -87,7 +87,7 @@
8787
<p>CoderDojo の雰囲気は掴めたでしょうか? もっと詳しく知るには<strong>実際に参加してみるのが近道</strong>です。<%= link_to '日本の道場一覧', root_path(anchor: 'dojos') %></a><%= link_to '近日開催の道場', events_path %>、もしくは<%= link_to '地図情報(DojoMap)', dojomap_url %> から最寄りの道場を探してみましょう!</p>
8888

8989
<div class='btn-cover' style="margin-top: 20px; margin-bottom: 100px;">
90-
<%= link_to '/events', class: 'btn-blue' do %>
90+
<%= link_to events_path, class: 'btn-blue' do %>
9191
📆
9292
近日開催から探す
9393
<% end %>
@@ -250,7 +250,7 @@
250250
</li>
251251
</ul>
252252

253-
253+
254254
<h3 id='media-articles' style='margin-top: 80px;'>
255255
<a href='#media-articles'>📜</a>
256256
Web記事・プレスリリース
@@ -674,7 +674,7 @@
674674
</a>
675675
</div>
676676

677-
677+
678678
<h3 id='challenge-contests'>
679679
<a href='#challenge-contests'>🏅</a>
680680
コンテスト
@@ -895,7 +895,7 @@
895895
</ul>
896896
<br>
897897
<p>具体的なイメージが掴めたら、準備・申請の手続きを進めていきましょう!</p>
898-
898+
899899
<h3 id='startup-flowchart'>
900900
<a href='#startup-flowchart'>☯️</a>
901901
Dojo の設立・初回開催までの流れ<span style="font-size: 20px; font-weight: 400;">(制作: <a href="https://coderdojo-kodaira.github.io/">CoderDojo Kodaira</a></span>
@@ -1328,7 +1328,7 @@
13281328
<h4 id='doc-safeguarding-checklist'><%= link_to 'ボランティアのための子ども安全保護チェックリスト', 'https://raspberrypi.my.salesforce.com/sfc/p/#4J000000GeqW/a/8d000000PGbW/TH92cMY9bA.gvpWJx0xXME.cFddNiDAEZ0rG4ciel00' %><small>(英語)</small></h4>
13291329
<p>by <%= link_to 'Raspberry Pi & CoderDojo Foundation', raspi_url %></p>
13301330
</li>
1331-
1331+
13321332
<li>
13331333
<h4 id='doc-start-a-coderdojo'><a href="https://www.futurelearn.com/info/courses/start-a-coder-dojo/0/steps/40617">Start a CoderDojo - What is CoderDojo?</a><small>(英語)</small></h4>
13341334
<p>by <%= link_to 'Raspberry Pi & CoderDojo Foundation', raspi_url %></p>

spec/requests/docs_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@
2323
expect(response.status).to eq 302
2424
end
2525

26+
# /kata page internal links should not be dead links
27+
context 'kata page - internal links check' do
28+
it 'has no dead internal links' do
29+
get '/kata'
30+
doc = Nokogiri::HTML(response.body)
31+
links = doc.css('a[href]').map { |a| a['href'] }
32+
.select { |href| href.start_with?('/') && !href.start_with?('/#') }
33+
.map { |href| href.split('#').first }
34+
.uniq
35+
36+
dead_links = links.reject do |path|
37+
get path
38+
response.status < 400
39+
end
40+
41+
puts "Checked #{links.count} internal links"
42+
expect(dead_links).to be_empty, "Dead links found: #{dead_links.join(', ')}"
43+
end
44+
end
45+
2646
# /signup page has Google Form to be rendered.
2747
context 'signup page - Google Form rendering (Critical)' do
2848
before { get doc_path('signup') }

0 commit comments

Comments
 (0)