Skip to content

Commit

Permalink
Fix linting and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitjalan committed Nov 22, 2023
1 parent 820163d commit 1bb3750
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ def before_head_close_meta(controller)
"datePublished" => topic.created_at,
"author" => {
"@type" => "Person",
"username" => topic.user&.username,
"url" => topic.user&.full_url
"name" => topic.user&.username,
"url" => topic.user&.full_url,
},
}

Expand All @@ -325,7 +325,7 @@ def before_head_close_meta(controller)
"author" => {
"@type" => "Person",
"name" => accepted_answer.user&.username,
"url" => accepted_answer.user&.full_url
"url" => accepted_answer.user&.full_url,
},
}
else
Expand Down
8 changes: 5 additions & 3 deletions spec/requests/topics_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@
def schema_json(answerCount)
if answerCount > 0
answer_json =
',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"dateCreated":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}"}}' %
',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"datePublished":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}","url":"%{user2_url}"}}' %
{
answer_text: p2.excerpt,
answer_likes: p2.like_count,
answered_at: p2.created_at.as_json,
answer_url: p2.full_url,
username2: p2.user&.username,
user2_url: p2.user&.full_url,
}
else
answer_json = ""
end

# rubocop:todo Layout/LineLength
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"dateCreated":"%{created_at}","author":{"@type":"Person","name":"%{username1}"}%{answer_json}}}</script>' %
'<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"datePublished":"%{created_at}","author":{"@type":"Person","name":"%{username1}","url":"%{user1_url}"}%{answer_json}}}</script>' %
# rubocop:enable Layout/LineLength
{
title: topic.title,
question_text: p1.excerpt,
question_likes: p1.like_count,
answerCount: answerCount,
created_at: topic.created_at.as_json,
username1: topic.user&.name,
username1: topic.user&.username,
user1_url: topic.user&.full_url,
answer_json: answer_json,
}
end
Expand Down

0 comments on commit 1bb3750

Please sign in to comment.