From 9f90125fa75b40d595d8d84a8eaea0161cc3dff0 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Aug 2022 13:29:40 +0200 Subject: [PATCH] Add attribute anchor to link Anchor needs to be added to the link to redirect directly to the comments section. --- app/views/legislation/questions/_question.html.erb | 2 +- spec/system/legislation/questions_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/legislation/questions/_question.html.erb b/app/views/legislation/questions/_question.html.erb index 7c91b52ca..aa910883c 100644 --- a/app/views/legislation/questions/_question.html.erb +++ b/app/views/legislation/questions/_question.html.erb @@ -8,7 +8,7 @@
<%= render Shared::CommentsCountComponent.new( question.comments.count, - url: legislation_process_question_path(question.process, question) + url: legislation_process_question_path(question.process, question, anchor: "comments") ) %> ยท <%= l question.created_at.to_date %>
diff --git a/spec/system/legislation/questions_spec.rb b/spec/system/legislation/questions_spec.rb index bbf55184c..b217ad7f4 100644 --- a/spec/system/legislation/questions_spec.rb +++ b/spec/system/legislation/questions_spec.rb @@ -109,5 +109,15 @@ describe "Legislation" do expect(page).not_to have_selector(:link_or_button, "Submit answer") end + + scenario "render link to questions comments with anchor" do + question = create(:legislation_question, process: process, title: "Question without comments") + + visit legislation_process_path(process) + + expect(page).to have_link "No comments", href: legislation_process_question_path(process, + question, + anchor: "comments") + end end end