Unify create comments specs
This commit is contained in:
@@ -38,6 +38,10 @@ FactoryBot.define do
|
||||
after(:create) { |poll| create(:image, imageable: poll) }
|
||||
end
|
||||
|
||||
trait :with_author do
|
||||
author factory: :user
|
||||
end
|
||||
|
||||
transient { officers { [] } }
|
||||
|
||||
after(:create) do |poll, evaluator|
|
||||
@@ -45,6 +49,8 @@ FactoryBot.define do
|
||||
create(:poll_officer_assignment, poll: poll, officer: officer)
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_with_author, traits: [:with_author]
|
||||
end
|
||||
|
||||
factory :poll_question, class: "Poll::Question" do
|
||||
|
||||
@@ -6,22 +6,6 @@ describe "Commenting Budget::Investments" do
|
||||
|
||||
it_behaves_like "flaggable", :budget_investment_comment
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
|
||||
@@ -25,19 +25,6 @@ describe "Commenting debates" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(1)"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Hide" do
|
||||
scenario "Without replies" do
|
||||
create(:comment, commentable: debate, user: user, body: "This was a mistake")
|
||||
|
||||
@@ -6,19 +6,6 @@ describe "Commenting legislation questions" do
|
||||
|
||||
it_behaves_like "flaggable", :legislation_annotation_comment
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit polymorphic_path(annotation)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(2)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
|
||||
@@ -10,19 +10,6 @@ describe "Commenting legislation questions" do
|
||||
it_behaves_like "flaggable", :legislation_question_comment
|
||||
end
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
fill_in "Leave your answer", with: "Have you thought about...?"
|
||||
click_button "Publish answer"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
|
||||
@@ -4,22 +4,6 @@ describe "Commenting polls" do
|
||||
let(:user) { create(:user) }
|
||||
let(:poll) { create(:poll, author: create(:user)) }
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit poll_path(poll)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
|
||||
@@ -6,22 +6,6 @@ describe "Commenting proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :proposal_comment
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
|
||||
@@ -6,25 +6,6 @@ describe "Commenting topics from proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :topic_with_community_comment
|
||||
|
||||
scenario "Create" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
login_as(user)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -353,25 +334,6 @@ describe "Commenting topics from budget investments" do
|
||||
let(:user) { create(:user) }
|
||||
let(:investment) { create(:budget_investment) }
|
||||
|
||||
scenario "Create" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
login_as(user)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
@@ -7,7 +7,7 @@ describe "Comments" do
|
||||
:debate,
|
||||
:legislation_annotation,
|
||||
:legislation_question,
|
||||
:poll,
|
||||
:poll_with_author,
|
||||
:proposal,
|
||||
:topic_with_community,
|
||||
:topic_with_investment_community
|
||||
@@ -280,6 +280,32 @@ describe "Comments" do
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
end
|
||||
|
||||
scenario "Create" do
|
||||
login_as(user)
|
||||
visit polymorphic_path(resource)
|
||||
|
||||
fill_in fill_text, with: "Have you thought about...?"
|
||||
click_button button_text
|
||||
|
||||
if [:debate, :legislation_question].include?(factory)
|
||||
within "#comments" do
|
||||
expect(page).to have_content "(1)"
|
||||
end
|
||||
elsif factory == :legislation_annotation
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Comments (2)"
|
||||
end
|
||||
else
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on create" do
|
||||
login_as(user)
|
||||
visit polymorphic_path(resource)
|
||||
|
||||
Reference in New Issue
Block a user