diff --git a/spec/factories/classifications.rb b/spec/factories/classifications.rb index 00b4b2d5b..489b5004a 100644 --- a/spec/factories/classifications.rb +++ b/spec/factories/classifications.rb @@ -34,7 +34,12 @@ FactoryBot.define do community { create(:proposal).community } end + trait :with_investment_community do + community { create(:budget_investment).community } + end + factory :topic_with_community, traits: [:with_community] + factory :topic_with_investment_community, traits: [:with_investment_community] end factory :related_content do diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 2168faf04..ab4e4da85 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -204,19 +204,6 @@ describe "Commenting Budget::Investments" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: investment) - visit budget_investment_path(investment.budget, investment) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do login_as(user) visit budget_investment_path(investment.budget, investment) diff --git a/spec/system/comments/debates_spec.rb b/spec/system/comments/debates_spec.rb index 4b2969658..82daad555 100644 --- a/spec/system/comments/debates_spec.rb +++ b/spec/system/comments/debates_spec.rb @@ -207,19 +207,6 @@ describe "Commenting debates" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: debate) - visit debate_path(debate) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do login_as(user) visit debate_path(debate) diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 3e779b7bb..d2c1b60a2 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -201,19 +201,6 @@ describe "Commenting legislation questions" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: annotation) - visit polymorphic_path(annotation) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do login_as(user) visit polymorphic_path(annotation) diff --git a/spec/system/comments/legislation_questions_spec.rb b/spec/system/comments/legislation_questions_spec.rb index 3e11e573a..1836d1bd6 100644 --- a/spec/system/comments/legislation_questions_spec.rb +++ b/spec/system/comments/legislation_questions_spec.rb @@ -196,19 +196,6 @@ describe "Commenting legislation questions" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: question) - visit legislation_process_question_path(question.process, question) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" 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 94568a747..3c8fb54ce 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -185,19 +185,6 @@ describe "Commenting polls" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: poll) - visit poll_path(poll) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do login_as(user) visit poll_path(poll) diff --git a/spec/system/comments/proposals_spec.rb b/spec/system/comments/proposals_spec.rb index 505743a60..de5e2c24c 100644 --- a/spec/system/comments/proposals_spec.rb +++ b/spec/system/comments/proposals_spec.rb @@ -190,19 +190,6 @@ describe "Commenting proposals" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - create(:comment, commentable: proposal) - visit proposal_path(proposal) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do login_as(user) visit proposal_path(proposal) diff --git a/spec/system/comments/topics_spec.rb b/spec/system/comments/topics_spec.rb index b8b6852b7..4e47f71e7 100644 --- a/spec/system/comments/topics_spec.rb +++ b/spec/system/comments/topics_spec.rb @@ -202,22 +202,6 @@ describe "Commenting topics from proposals" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - community = proposal.community - topic = create(:topic, community: community) - create(:comment, commentable: topic) - - visit community_topic_path(community, topic) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do community = proposal.community topic = create(:topic, community: community) @@ -751,22 +735,6 @@ describe "Commenting topics from budget investments" do expect(page).to have_current_path(/#comments/, url: true) end - describe "Not logged user" do - scenario "can not see comments forms" do - community = investment.community - topic = create(:topic, community: community) - create(:comment, commentable: topic) - - visit community_topic_path(community, topic) - - expect(page).to have_content "You must sign in or sign up to leave a comment" - within("#comments") do - expect(page).not_to have_content "Write a comment" - expect(page).not_to have_content "Reply" - end - end - end - scenario "Create" do community = investment.community topic = create(:topic, community: community) diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb new file mode 100644 index 000000000..7a8f3a099 --- /dev/null +++ b/spec/system/comments_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +describe "Comments" do + let(:factory) { + [ + :budget_investment, + :debate, + :legislation_annotation, + :legislation_question, + :poll, + :proposal, + :topic_with_community, + :topic_with_investment_community + ].sample + } + let(:resource) { create(factory) } + let(:fill_text) do + if factory == :legislation_question + "Leave your answer" + else + "Leave your comment" + end + end + + describe "Not logged user" do + scenario "can not see comments forms" do + create(:comment, commentable: resource) + + visit polymorphic_path(resource) + + expect(page).to have_content "You must sign in or sign up to leave a comment" + within("#comments") do + expect(page).not_to have_content fill_text + expect(page).not_to have_content "Reply" + end + end + end +end