diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 04209b671..d6bd2a097 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -6,33 +6,6 @@ describe "Commenting Budget::Investments" do it_behaves_like "flaggable", :budget_investment_comment describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: investment, user: citizen) - - login_as(manuela) - visit budget_investment_path(investment.budget, investment) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 52889b46a..99159a7f7 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -126,33 +126,6 @@ describe "Commenting debates" do end describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: debate, user: citizen) - - login_as(manuela) - visit debate_path(debate) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 8c62f8fbd..2806be52c 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -21,34 +21,6 @@ describe "Commenting legislation questions" do end describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - annotation = create(:legislation_annotation, author: citizen) - comment = annotation.comments.first - - login_as(manuela) - visit polymorphic_path(annotation) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 41f5febad..eff50ac1f 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -23,33 +23,6 @@ describe "Commenting legislation questions" do end describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: question, user: citizen) - - login_as(manuela) - visit legislation_process_question_path(question.process, question) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your answer", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 37c4c7f13..946675637 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -5,33 +5,6 @@ describe "Commenting polls" do let(:poll) { create(:poll, author: create(:user)) } describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: poll, user: citizen) - - login_as(manuela) - visit poll_path(poll) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index ff716414f..d64e56a25 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -6,33 +6,6 @@ describe "Commenting proposals" do it_behaves_like "flaggable", :proposal_comment describe "Moderators" do - scenario "can create reply as a moderator" do - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: proposal, user: citizen) - - login_as(manuela) - visit proposal_path(proposal) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do moderator = create(:moderator) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index 7d6ddf3c4..608a02a71 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -6,35 +6,6 @@ describe "Commenting topics from proposals" do it_behaves_like "flaggable", :topic_with_community_comment describe "Moderators" do - scenario "can create reply as a moderator" do - community = proposal.community - topic = create(:topic, community: community) - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: topic, user: citizen) - - login_as(manuela) - visit community_topic_path(community, topic) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do community = proposal.community topic = create(:topic, community: community) @@ -210,35 +181,6 @@ describe "Commenting topics from budget investments" do let(:investment) { create(:budget_investment) } describe "Moderators" do - scenario "can create reply as a moderator" do - community = investment.community - topic = create(:topic, community: community) - citizen = create(:user, username: "Ana") - manuela = create(:user, username: "Manuela") - moderator = create(:moderator, user: manuela) - comment = create(:comment, commentable: topic, user: citizen) - - login_as(manuela) - visit community_topic_path(community, topic) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "I am moderating!" - check "comment-as-moderator-comment_#{comment.id}" - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "I am moderating!" - expect(page).to have_content "Moderator ##{moderator.id}" - expect(page).to have_css "div.is-moderator" - expect(page).to have_css "img.moderator-avatar" - end - - expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" - end - scenario "can not comment as an administrator" do community = investment.community topic = create(:topic, community: community) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index 64481066f..f51828bd2 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -418,6 +418,35 @@ describe "Comments" do expect(page).to have_css "img.moderator-avatar" end end + + scenario "can create reply as a moderator" do + citizen = create(:user, username: "Ana") + manuela = create(:user, username: "Manuela") + moderator = create(:moderator, user: manuela) + comment = create(:comment, commentable: resource, user: citizen) + + login_as(manuela) + visit polymorphic_path(resource) + + within "#comment_#{comment.id}" do + click_link "Reply" + end + + within "#js-comment-form-comment_#{comment.id}" do + fill_in fill_text, with: "I am moderating!" + check "Comment as moderator" + click_button "Publish reply" + end + + within "#comment_#{comment.id}" do + expect(page).to have_content "I am moderating!" + expect(page).to have_content "Moderator ##{moderator.id}" + expect(page).to have_css "div.is-moderator" + expect(page).to have_css "img.moderator-avatar" + end + + expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}" + end end scenario "Errors on create" do