diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index d832b9dec..c5fcb422e 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -6,24 +6,6 @@ describe "Commenting Budget::Investments" do it_behaves_like "flaggable", :budget_investment_comment - scenario "Index" do - not_valuations = 3.times.map { create(:comment, commentable: investment) } - create(:comment, :valuation, commentable: investment, subject: "Not viable") - - visit budget_investment_path(investment.budget, investment) - - expect(page).to have_css(".comment", count: 3) - expect(page).not_to have_content("Not viable") - - within("#comments") do - not_valuations.each do |comment| - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - end - scenario "Show" do parent_comment = create(:comment, commentable: investment, body: "Parent") create(:comment, commentable: investment, parent: parent_comment, body: "First subcomment") diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 7e30e78a0..9a8b64761 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -6,21 +6,6 @@ describe "Commenting debates" do it_behaves_like "flaggable", :debate_comment - scenario "Index" do - 3.times { create(:comment, commentable: debate) } - comment = Comment.includes(:user).last - - visit debate_path(debate) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do parent_comment = create(:comment, commentable: debate, body: "Parent") create(:comment, commentable: debate, parent: parent_comment, body: "First subcomment") diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 4841aab1c..ff3a228f7 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -6,21 +6,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_annotation_comment - scenario "Index" do - 3.times { create(:comment, commentable: annotation) } - comment = Comment.includes(:user).last - - visit polymorphic_path(annotation) - - expect(page).to have_css(".comment", count: 4) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do href = polymorphic_path(annotation) parent_comment = create(:comment, commentable: annotation, body: "Parent") diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 911d8d783..30affdcf0 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -10,21 +10,6 @@ describe "Commenting legislation questions" do it_behaves_like "flaggable", :legislation_question_comment end - scenario "Index" do - 3.times { create(:comment, commentable: question) } - comment = Comment.includes(:user).last - - visit legislation_process_question_path(question.process, question) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do href = legislation_process_question_path(question.process, question) parent_comment = create(:comment, commentable: question, body: "Parent") diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 66e762818..23d1b9f38 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 "Index" do - 3.times { create(:comment, commentable: poll) } - comment = Comment.includes(:user).last - - visit poll_path(poll) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do parent_comment = create(:comment, commentable: poll, body: "Parent") create(:comment, commentable: poll, parent: parent_comment, body: "First subcomment") diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index b27281346..9606219e0 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 "Index" do - 3.times { create(:comment, commentable: proposal) } - comment = Comment.includes(:user).last - - visit proposal_path(proposal) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do parent_comment = create(:comment, commentable: proposal, body: "Parent") create(:comment, commentable: proposal, parent: parent_comment, body: "First subcomment") diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index eec55ff6b..858922cd7 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 "Index" do - community = proposal.community - topic = create(:topic, community: community) - create_list(:comment, 3, commentable: topic) - comment = Comment.includes(:user).last - - visit community_topic_path(community, topic) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do community = proposal.community topic = create(:topic, community: community) @@ -549,23 +532,6 @@ describe "Commenting topics from budget investments" do let(:user) { create(:user) } let(:investment) { create(:budget_investment) } - scenario "Index" do - community = investment.community - topic = create(:topic, community: community) - create_list(:comment, 3, commentable: topic) - comment = Comment.includes(:user).last - - visit community_topic_path(community, topic) - - expect(page).to have_css(".comment", count: 3) - - within first(".comment") do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body - end - end - scenario "Show" do community = investment.community topic = create(:topic, community: community) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index 753d5ffec..b06822b94 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -36,6 +36,53 @@ describe "Comments" do end end + describe "Index" do + context "Budget Investments" do + let(:investment) { create(:budget_investment) } + + scenario "render comments" do + not_valuations = 3.times.map { create(:comment, commentable: investment) } + create(:comment, :valuation, commentable: investment, subject: "Not viable") + + visit budget_investment_path(investment.budget, investment) + + expect(page).to have_css(".comment", count: 3) + expect(page).not_to have_content("Not viable") + + within("#comments") do + not_valuations.each do |comment| + expect(page).to have_content comment.user.name + expect(page).to have_content I18n.l(comment.created_at, format: :datetime) + expect(page).to have_content comment.body + end + end + end + end + + context "Debates, annotations, question, Polls, Proposals and Topics" do + let(:factory) { (factories - [:budget_investment]).sample } + + scenario "render comments" do + 3.times { create(:comment, commentable: resource) } + comment = Comment.includes(:user).last + + visit polymorphic_path(resource) + + if factory == :legislation_annotation + expect(page).to have_css(".comment", count: 4) + else + expect(page).to have_css(".comment", count: 3) + end + + within first(".comment") do + expect(page).to have_content comment.user.name + expect(page).to have_content I18n.l(comment.created_at, format: :datetime) + expect(page).to have_content comment.body + end + end + end + end + describe "Not logged user" do scenario "can not see comments forms" do create(:comment, commentable: resource)