From d4f3680dccf2f323facab219b7ac3ead71990f1b Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 19 Dec 2023 18:23:44 +0100 Subject: [PATCH] Unify reply update parent comments specs --- spec/system/comments/budget_investments_spec.rb | 15 --------------- spec/system/comments/debates_spec.rb | 15 --------------- .../comments/legislation_annotations_spec.rb | 17 ----------------- .../comments/legislation_questions_spec.rb | 16 ---------------- 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 | 15 +++++++++++++++ 8 files changed, 15 insertions(+), 110 deletions(-) diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 6712a7425..75323c477 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 "Reply update parent comment responses count" do - comment = create(:comment, commentable: investment) - - login_as(create(:user)) - visit budget_investment_path(investment.budget, investment) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do comment = create(:comment, commentable: investment) create(:comment, commentable: investment, parent: comment) diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index b1ac6a21a..a3f21b7e0 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -102,21 +102,6 @@ describe "Commenting debates" do end end - scenario "Reply update parent comment responses count" do - comment = create(:comment, commentable: debate) - - login_as(create(:user)) - visit debate_path(debate) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do comment = create(:comment, commentable: debate) create(:comment, commentable: debate, parent: comment) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 0c62fee2f..cb6326cf2 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -6,23 +6,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_annotation_comment - scenario "Reply update parent comment responses count" do - manuela = create(:user, :level_two, username: "Manuela") - annotation = create(:legislation_annotation) - comment = annotation.comments.first - - login_as(manuela) - visit polymorphic_path(annotation) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do manuela = create(:user, :level_two, username: "Manuela") annotation = create(:legislation_annotation) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 925f7c07d..51fcd8725 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -10,22 +10,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_question_comment end - scenario "Reply update parent comment responses count" do - manuela = create(:user, :level_two, username: "Manuela") - comment = create(:comment, commentable: question) - - login_as(manuela) - visit legislation_process_question_path(question.process, question) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your answer", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do manuela = create(:user, :level_two, username: "Manuela") comment = create(:comment, commentable: question) diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 4f48a1a61..2a13ff127 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 "Reply update parent comment responses count" do - comment = create(:comment, commentable: poll) - - login_as(create(:user)) - visit poll_path(poll) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do comment = create(:comment, commentable: poll) create(:comment, commentable: poll, parent: comment) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index a16b36763..921939d74 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 "Reply update parent comment responses count" do - comment = create(:comment, commentable: proposal) - - login_as(create(:user)) - visit proposal_path(proposal) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do comment = create(:comment, commentable: proposal) create(:comment, commentable: proposal, parent: comment) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index 9075cfbf9..ba8ec51cb 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 "Reply update parent comment responses count" do - community = proposal.community - topic = create(:topic, community: community) - comment = create(:comment, commentable: topic) - - login_as(create(:user)) - visit community_topic_path(community, topic) - - within ".comment", text: comment.body do - click_link "Reply" - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - - expect(page).to have_content("1 response (collapse)") - end - end - scenario "Reply show parent comments responses when hidden" do community = proposal.community topic = create(:topic, community: community) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index b9172992e..b49670536 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -328,6 +328,21 @@ describe "Comments" do expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" end + scenario "Reply update parent comment responses count" do + comment = create(:comment, commentable: resource) + + login_as(user) + visit polymorphic_path(resource) + + within ".comment", text: comment.body do + click_link "Reply" + fill_in fill_text, with: "It will be done next week." + click_button "Publish reply" + + expect(page).to have_content("1 response (collapse)") + end + end + scenario "Errors on create" do login_as(user) visit polymorphic_path(resource)