From 0154bc556d92cede96ae5ee66a1b4bcf13763728 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 30 May 2019 00:34:18 +0200 Subject: [PATCH] Add link to comment path on comment date --- app/views/comments/_comment.html.erb | 7 ++++++- .../comments/budget_investments_spec.rb | 15 +++++++++++++++ spec/features/comments/debates_spec.rb | 15 +++++++++++++++ .../comments/legislation_annotations_spec.rb | 16 ++++++++++++++++ .../comments/legislation_questions_spec.rb | 15 +++++++++++++++ spec/features/comments/polls_spec.rb | 15 +++++++++++++++ spec/features/comments/proposals_spec.rb | 15 +++++++++++++++ spec/features/comments/topics_spec.rb | 17 +++++++++++++++++ 8 files changed, 114 insertions(+), 1 deletion(-) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 886a39aaa..e1dd210b6 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -61,7 +61,12 @@ <% end %> -  • <%= l comment.created_at.to_datetime, format: :datetime %> +  •  + + <%= link_to comment_path(comment) do %> + <%= l comment.created_at.to_datetime, format: :datetime %> + <% end %> +
li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: investment, user: user) + + visit budget_investment_path(investment.budget, investment) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{investment.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = create(:comment, body: "Main comment", commentable: investment) child_comment = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment) diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index c8e17f170..67f6f6efb 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -39,6 +39,21 @@ describe "Commenting debates" do expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: debate, user: user) + + visit debate_path(debate) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{debate.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = create(:comment, body: "Main comment", commentable: debate) child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment) diff --git a/spec/features/comments/legislation_annotations_spec.rb b/spec/features/comments/legislation_annotations_spec.rb index 5b608058a..cef55ddac 100644 --- a/spec/features/comments/legislation_annotations_spec.rb +++ b/spec/features/comments/legislation_annotations_spec.rb @@ -44,6 +44,22 @@ describe "Commenting legislation questions" do expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: legislation_annotation, user: user) + + visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, + legislation_annotation.draft_version, + legislation_annotation) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + click_link comment.created_at.strftime("%Y-%m-%d %T") + end + + expect(page).to have_link "Go back to #{legislation_annotation.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = legislation_annotation.comments.first child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment) diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index 67be1f55d..9a7757016 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -46,6 +46,21 @@ describe "Commenting legislation questions" do expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: legislation_question, user: user) + + visit legislation_process_question_path(legislation_question.process, legislation_question) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{legislation_question.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = create(:comment, body: "Main comment", commentable: legislation_question) child_comment = create(:comment, body: "First subcomment", commentable: legislation_question, parent: parent_comment) diff --git a/spec/features/comments/polls_spec.rb b/spec/features/comments/polls_spec.rb index 1a4c20664..09c6611d2 100644 --- a/spec/features/comments/polls_spec.rb +++ b/spec/features/comments/polls_spec.rb @@ -40,6 +40,21 @@ describe "Commenting polls" do expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: poll, user: user) + + visit poll_path(poll) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{poll.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = create(:comment, body: "Main comment", commentable: poll) child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment) diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index d86b016a9..3325f632a 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -38,6 +38,21 @@ describe "Commenting proposals" do expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end + scenario "Link to comment show" do + comment = create(:comment, commentable: proposal, user: user) + + visit proposal_path(proposal) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{proposal.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do parent_comment = create(:comment, body: "Main comment", commentable: proposal) child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment) diff --git a/spec/features/comments/topics_spec.rb b/spec/features/comments/topics_spec.rb index b6b918055..193678b16 100644 --- a/spec/features/comments/topics_spec.rb +++ b/spec/features/comments/topics_spec.rb @@ -39,6 +39,23 @@ describe "Commenting topics from proposals" do expect(page).to have_link "Go back to #{topic.title}", href: community_topic_path(community, topic) end + scenario "Link to comment show" do + community = proposal.community + topic = create(:topic, community: community) + comment = create(:comment, commentable: topic, user: user) + + visit community_topic_path(community, topic) + + within "#comment_#{comment.id}" do + expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T") + end + + click_link comment.created_at.strftime("%Y-%m-%d %T") + + expect(page).to have_link "Go back to #{topic.title}" + expect(page).to have_current_path(comment_path(comment)) + end + scenario "Collapsable comments", :js do community = proposal.community topic = create(:topic, community: community)