From 0c58e7e3b4c44825efcb1e38020367e6a4e2ec28 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 14 Dec 2023 10:56:00 +0100 Subject: [PATCH] Unify link to comment show specs Note that, in all cases except in :legislation_annotation, the behavior for click_link is now slightly different. Previously, the click_link outsite of within block meant that we made sure there was only one link with that text in the whole page. Now, in order to unify this spec we change the behaviour. --- spec/system/comments/budget_investments_spec.rb | 15 --------------- spec/system/comments/debates_spec.rb | 15 --------------- .../comments/legislation_annotations_spec.rb | 14 -------------- .../comments/legislation_questions_spec.rb | 15 --------------- spec/system/comments/polls_spec.rb | 15 --------------- spec/system/comments/proposals_spec.rb | 15 --------------- spec/system/comments/topics_spec.rb | 17 ----------------- spec/system/comments_spec.rb | 13 +++++++++++++ 8 files changed, 13 insertions(+), 106 deletions(-) diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 0f2a15e81..c4fd205b5 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -6,21 +6,6 @@ describe "Commenting Budget::Investments" do it_behaves_like "flaggable", :budget_investment_comment - 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" do parent_comment = create(:comment, body: "Main comment", commentable: investment) child_comment = create(:comment, diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 58db0c99e..74535dd26 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -6,21 +6,6 @@ describe "Commenting debates" do it_behaves_like "flaggable", :debate_comment - 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" 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/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 75651d10d..3d3fb1ad4 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -6,20 +6,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_annotation_comment - scenario "Link to comment show" do - comment = create(:comment, commentable: annotation, user: user) - - visit polymorphic_path(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 #{annotation.title}" - expect(page).to have_current_path(comment_path(comment)) - end - scenario "Collapsable comments" do parent_comment = annotation.comments.first child_comment = create(:comment, diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 4a542df4f..7b792ed1c 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -10,21 +10,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_question_comment end - scenario "Link to comment show" do - comment = create(:comment, commentable: question, user: user) - - visit legislation_process_question_path(question.process, 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 #{question.title}" - expect(page).to have_current_path(comment_path(comment)) - end - scenario "Collapsable comments" do parent_comment = create(:comment, body: "Main comment", commentable: question) child_comment = create(:comment, body: "First subcomment", commentable: question, parent: parent_comment) diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 46c4b90f8..4071e9cf2 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -4,21 +4,6 @@ describe "Commenting polls" do let(:user) { create(:user) } let(:poll) { create(:poll, author: create(:user)) } - 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" 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/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index 4a7ba282b..18787cdc1 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -6,21 +6,6 @@ describe "Commenting proposals" do it_behaves_like "flaggable", :proposal_comment - 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" 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/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index 528e30362..ca0cf37cb 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -6,23 +6,6 @@ describe "Commenting topics from proposals" do it_behaves_like "flaggable", :topic_with_community_comment - 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" do community = proposal.community topic = create(:topic, community: community) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index a31afbb45..7b40ab7a8 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -103,6 +103,19 @@ describe "Comments" do end end + scenario "Link to comment show" do + comment = create(:comment, commentable: resource, user: user) + + visit polymorphic_path(resource) + + within "#comment_#{comment.id}" do + click_link comment.created_at.strftime("%Y-%m-%d %T") + end + + expect(page).to have_link "Go back to #{resource.title}" + expect(page).to have_current_path(comment_path(comment)) + end + describe "Not logged user" do scenario "can not see comments forms" do create(:comment, commentable: resource)