From e1e80c3cc9aa709da2eb36f53f98053f4cbc5084 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 Jan 2018 17:21:42 +0100 Subject: [PATCH] adds specs --- spec/features/admin/comments_spec.rb | 39 +++++++++++++++++++++++ spec/features/moderation/comments_spec.rb | 26 +++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/spec/features/admin/comments_spec.rb b/spec/features/admin/comments_spec.rb index e6e603378..1f87bc105 100644 --- a/spec/features/admin/comments_spec.rb +++ b/spec/features/admin/comments_spec.rb @@ -26,6 +26,45 @@ feature 'Admin comments' do expect(page).not_to have_content("Good Proposal!") end + scenario "Visit items with hidden comments" do + debate = create(:debate, title: "Debate with spam comment") + proposal = create(:proposal, title: "Proposal with spam comment") + create(:comment, :hidden, commentable: debate, body: "This is SPAM comment on debate") + create(:comment, :hidden, commentable: proposal, body: "This is SPAM comment on proposal") + + visit admin_comments_path + + expect(page).to have_content("Debate with spam comment") + expect(page).to have_content("Proposal with spam comment") + expect(page).to have_content("This is SPAM comment on debate") + expect(page).to have_content("This is SPAM comment on proposal") + + click_link "Debate with spam comment" + expect(page).to have_content("Debate with spam comment") + expect(page).not_to have_content("This is SPAM comment on debate") + + visit admin_comments_path + + click_link "Proposal with spam comment" + expect(page).to have_content("Proposal with spam comment") + expect(page).not_to have_content("This is SPAM comment on proposal") + end + + scenario "Don't show link on hidden items" do + debate = create(:debate, :hidden, title: "Hidden debate title") + proposal = create(:proposal, :hidden, title: "Hidden proposal title") + create(:comment, :hidden, commentable: debate, body: "This is SPAM comment on debate") + create(:comment, :hidden, commentable: proposal, body: "This is SPAM comment on proposal") + + visit admin_comments_path + + expect(page).to have_content("(Hidden proposal: Hidden proposal title)") + expect(page).to have_content("(Hidden debate: Hidden debate title)") + + expect(page).not_to have_link("This is SPAM comment on debate") + expect(page).not_to have_link("This is SPAM comment on proposal") + end + scenario "Restore" do comment = create(:comment, :hidden, body: 'Not really SPAM') visit admin_comments_path diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb index 72f1f55f9..365f4e79d 100644 --- a/spec/features/moderation/comments_spec.rb +++ b/spec/features/moderation/comments_spec.rb @@ -37,6 +37,32 @@ feature 'Moderate comments' do end end + scenario "Visit items with flagged comments" do + moderator = create(:moderator) + debate = create(:debate, title: "Debate with spam comment") + proposal = create(:proposal, title: "Proposal with spam comment") + create(:comment, commentable: debate, body: "This is SPAM comment on debate", flags_count: 2) + create(:comment, commentable: proposal, body: "This is SPAM comment on proposal", flags_count: 2) + + login_as(moderator.user) + visit moderation_comments_path + + expect(page).to have_content("Debate with spam comment") + expect(page).to have_content("Proposal with spam comment") + expect(page).to have_content("This is SPAM comment on debate") + expect(page).to have_content("This is SPAM comment on proposal") + + click_link "Debate with spam comment" + expect(page).to have_content("Debate with spam comment") + expect(page).to have_content("This is SPAM comment on debate") + + visit moderation_comments_path + + click_link "Proposal with spam comment" + expect(page).to have_content("Proposal with spam comment") + expect(page).to have_content("This is SPAM comment on proposal") + end + feature '/moderation/ screen' do background do