From 154fb19b87642f6fdf12e7f6e46512ddb3be9d23 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 19 Dec 2023 19:01:41 +0100 Subject: [PATCH] Unify erasing a comment's author comments specs --- .../comments/budget_investments_spec.rb | 12 -------- spec/system/comments/debates_spec.rb | 12 -------- .../comments/legislation_annotations_spec.rb | 13 --------- .../comments/legislation_questions_spec.rb | 11 -------- spec/system/comments/polls_spec.rb | 12 -------- spec/system/comments/proposals_spec.rb | 12 -------- spec/system/comments/topics_spec.rb | 28 ------------------- spec/system/comments_spec.rb | 11 ++++++++ 8 files changed, 11 insertions(+), 100 deletions(-) diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index ac1d7fc11..267f2a023 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -5,18 +5,6 @@ describe "Commenting Budget::Investments" do it_behaves_like "flaggable", :budget_investment_comment - scenario "Erasing a comment's author" do - investment = create(:budget_investment) - comment = create(:comment, commentable: investment, body: "this should be visible") - comment.user.erase - - visit budget_investment_path(investment.budget, investment) - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - describe "Moderators" do scenario "can create comment as a moderator" do moderator = create(:moderator) diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 42f80bf8c..813f1c0c6 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -112,18 +112,6 @@ describe "Commenting debates" do end end - scenario "Erasing a comment's author" do - debate = create(:debate) - comment = create(:comment, commentable: debate, body: "this should be visible") - comment.user.erase - - visit debate_path(debate) - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - scenario "Submit button is disabled after clicking" do debate = create(:debate) login_as(user) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 36be4be02..ad3bbb15b 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -6,19 +6,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_annotation_comment - scenario "Erasing a comment's author" do - annotation = create(:legislation_annotation) - comment = create(:comment, commentable: annotation, body: "this should be visible") - comment.user.erase - - visit polymorphic_path(annotation) - - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - scenario "Submit button is disabled after clicking" do annotation = create(:legislation_annotation) login_as(user) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 550cd52f9..651fd056a 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -10,17 +10,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_question_comment end - scenario "Erasing a comment's author" do - comment = create(:comment, commentable: question, body: "this should be visible") - comment.user.erase - - visit legislation_process_question_path(question.process, question) - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - scenario "Submit button is disabled after clicking" do login_as(user) visit legislation_process_question_path(question.process, question) diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index cd5a83742..93bb91511 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -4,18 +4,6 @@ describe "Commenting polls" do let(:user) { create(:user) } let(:poll) { create(:poll, author: create(:user)) } - scenario "Erasing a comment's author" do - poll = create(:poll) - comment = create(:comment, commentable: poll, body: "this should be visible") - comment.user.erase - - visit poll_path(poll) - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - describe "Moderators" do scenario "can create comment as a moderator" do moderator = create(:moderator) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index b5f5a9dad..53a85970c 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -5,18 +5,6 @@ describe "Commenting proposals" do it_behaves_like "flaggable", :proposal_comment - scenario "Erasing a comment's author" do - proposal = create(:proposal) - comment = create(:comment, commentable: proposal, body: "this should be visible") - comment.user.erase - - visit proposal_path(proposal) - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - describe "Moderators" do scenario "can create comment as a moderator" do moderator = create(:moderator) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index da1a6b8cd..49d60285e 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -5,20 +5,6 @@ describe "Commenting topics from proposals" do it_behaves_like "flaggable", :topic_with_community_comment - scenario "Erasing a comment's author" do - community = proposal.community - topic = create(:topic, community: community) - comment = create(:comment, commentable: topic, body: "this should be visible") - comment.user.erase - - visit community_topic_path(community, topic) - - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - describe "Moderators" do scenario "can create comment as a moderator" do community = proposal.community @@ -243,20 +229,6 @@ describe "Commenting topics from budget investments" do let(:user) { create(:user) } let(:investment) { create(:budget_investment) } - scenario "Erasing a comment's author" do - community = investment.community - topic = create(:topic, community: community) - comment = create(:comment, commentable: topic, body: "this should be visible") - comment.user.erase - - visit community_topic_path(community, topic) - - within "#comment_#{comment.id}" do - expect(page).to have_content("User deleted") - expect(page).to have_content("this should be visible") - end - end - describe "Moderators" do scenario "can create comment as a moderator" do community = investment.community diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index c3ce37261..40612d6c2 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -389,6 +389,17 @@ describe "Comments" do expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment") end + scenario "Erasing a comment's author" do + comment = create(:comment, commentable: resource, body: "this should be visible") + comment.user.erase + + visit polymorphic_path(resource) + + within ".comment", text: "this should be visible" do + expect(page).to have_content("User deleted") + end + end + scenario "Errors on create" do login_as(user) visit polymorphic_path(resource)