From dbd419e75dcc26730af499d5ed2509eeb13dc8c3 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 19 Dec 2023 23:31:59 +0100 Subject: [PATCH] Unify voting comments show specs --- .../comments/budget_investments_spec.rb | 19 ---------- spec/system/comments/debates_spec.rb | 19 ---------- .../comments/legislation_annotations_spec.rb | 19 ---------- .../comments/legislation_questions_spec.rb | 19 ---------- spec/system/comments/polls_spec.rb | 19 ---------- spec/system/comments/proposals_spec.rb | 19 ---------- spec/system/comments/topics_spec.rb | 38 ------------------- spec/system/comments_spec.rb | 29 ++++++++++++++ 8 files changed, 29 insertions(+), 152 deletions(-) diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 80f938417..0a3134f42 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -81,25 +81,6 @@ describe "Commenting Budget::Investments" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit budget_investment_path(budget, investment) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit budget_investment_path(budget, investment) diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 8ee485193..fa5a5879c 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -135,25 +135,6 @@ describe "Commenting debates" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit debate_path(debate) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit debate_path(debate) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 8a3180e34..ceed86707 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -30,25 +30,6 @@ describe "Commenting legislation questions" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit polymorphic_path(annotation) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit polymorphic_path(annotation) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 182e36659..117850580 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -32,25 +32,6 @@ describe "Commenting legislation questions" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit legislation_process_question_path(question.process, question) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do 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 6a09125cf..e304814f0 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -14,25 +14,6 @@ describe "Commenting polls" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit poll_path(poll) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit poll_path(poll) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index 0df8f93e1..4d390c473 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -15,25 +15,6 @@ describe "Commenting proposals" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit proposal_path(proposal) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit proposal_path(proposal) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index 4d16f55ff..fc5c5e7c2 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -16,25 +16,6 @@ describe "Commenting topics from proposals" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit community_topic_path(proposal.community, topic) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit community_topic_path(proposal.community, topic) @@ -118,25 +99,6 @@ describe "Commenting topics from budget investments" do login_as(verified) end - scenario "Show" do - create(:vote, voter: verified, votable: comment, vote_flag: true) - create(:vote, voter: unverified, votable: comment, vote_flag: false) - - visit community_topic_path(investment.community, topic) - - within("#comment_#{comment.id}_votes") do - within(".in-favor") do - expect(page).to have_content "1" - end - - within(".against") do - expect(page).to have_content "1" - end - - expect(page).to have_content "2 votes" - end - end - scenario "Create" do visit community_topic_path(investment.community, topic) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index cdb40deb7..fc090b1f0 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -496,6 +496,35 @@ describe "Comments" do end end + describe "Voting comments" do + let(:verified) { create(:user, verified_at: Time.current) } + let(:unverified) { create(:user) } + let!(:comment) { create(:comment, commentable: resource) } + + before do + login_as(verified) + end + + scenario "Show" do + create(:vote, voter: verified, votable: comment, vote_flag: true) + create(:vote, voter: unverified, votable: comment, vote_flag: false) + + visit polymorphic_path(resource) + + within("#comment_#{comment.id}_votes") do + within(".in-favor") do + expect(page).to have_content "1" + end + + within(".against") do + expect(page).to have_content "1" + end + + expect(page).to have_content "2 votes" + end + end + end + scenario "Errors on create" do login_as(user) visit polymorphic_path(resource)