Skip to content

Commit

Permalink
Merge pull request #7991 from fjordllc/chore/truncate-qa-title-in-tit…
Browse files Browse the repository at this point in the history
…le-tag-logged-out

未ログイン時のQ&A個別ページのtitleタグの文字数を制限
  • Loading branch information
komagata authored Aug 21, 2024
2 parents c4519c7 + d8d8af0 commit 02a4bd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/views/unauthorized/_unauthorized_header.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- title "Q&A: #{truncate(title, length: 35, omission: '...')}"
- set_meta_tags og: { title: "Q&A: #{title}" }
header.unauthorized-header
.container
= image_tag('shared/piyo.svg', alt: 'フィヨルドブートキャンプのキャラクター画像', class: 'unauthorized-header__image')
Expand Down
17 changes: 17 additions & 0 deletions test/system/question/not_logged_in_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,21 @@ class Question::NotLoggedInTest < ApplicationSystemTestCase
assert_text 'このページの閲覧にはフィヨルドブートキャンプの入会が必要です'
assert_selector "meta[name='description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」のQ&A「#{question.title}」のページです。']", visible: false
end

test 'title of the title tag is truncated' do
question = questions(:question16)
visit question_path(question)
assert_selector 'title', text: 'Q&A: 長いタイトルの質問長いタイトルの質問長いタイトルの質問長いタイト... | FBC', visible: false
end

test 'titles in og:title, og:description, twitter:description tags is not truncated' do
question = questions(:question16)
visit question_path(question)
assert_selector "meta[property='og:title'][content='Q&A: 長いタイトルの質問長いタイトルの質問長いタイトルの質問長いタイトルの質問']",
visible: false
assert_selector "meta[property='og:description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」のQ&A「長いタイトルの質問長いタイトルの質問長いタイトルの質問長いタイトルの質問」のページです。']",
visible: false
assert_selector "meta[name='twitter:description'][content='オンラインプログラミングスクール「フィヨルドブートキャンプ」のQ&A「長いタイトルの質問長いタイトルの質問長いタイトルの質問長いタイトルの質問」のページです。']",
visible: false
end
end

0 comments on commit 02a4bd1

Please sign in to comment.