Update parent comment responses count when a new reply is created
Extract the needed portion of code to a new partial to be able to update only the elements needed when a new comment is added keeping UI properly updated.
This commit is contained in:
@@ -242,6 +242,21 @@ describe "Commenting Budget::Investments" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
comment = create(:comment, commentable: investment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: investment, user: user)
|
||||
|
||||
|
||||
@@ -216,6 +216,21 @@ describe "Internal valuation comments on Budget::Investments" do
|
||||
expect(page).not_to have_content("It will be done next week.")
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
|
||||
login_as(valuator_user)
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply without comment text", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
|
||||
|
||||
@@ -281,6 +281,21 @@ describe "Commenting debates" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
comment = create(:comment, commentable: debate)
|
||||
|
||||
login_as(create(:user))
|
||||
visit debate_path(debate)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: debate, user: user)
|
||||
|
||||
|
||||
@@ -278,6 +278,25 @@ describe "Commenting legislation questions" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
legislation_annotation = create(:legislation_annotation)
|
||||
comment = legislation_annotation.comments.first
|
||||
|
||||
login_as(manuela)
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = legislation_annotation.comments.first
|
||||
|
||||
|
||||
@@ -260,6 +260,22 @@ describe "Commenting legislation questions" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
comment = create(:comment, commentable: legislation_question)
|
||||
|
||||
login_as(manuela)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your answer", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: legislation_question, user: user)
|
||||
|
||||
|
||||
@@ -240,6 +240,21 @@ describe "Commenting polls" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
comment = create(:comment, commentable: poll)
|
||||
|
||||
login_as(create(:user))
|
||||
visit poll_path(poll)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: poll, user: user)
|
||||
|
||||
|
||||
@@ -238,6 +238,21 @@ describe "Commenting proposals" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
comment = create(:comment, commentable: proposal)
|
||||
|
||||
login_as(create(:user))
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: proposal, user: user)
|
||||
|
||||
|
||||
@@ -264,6 +264,23 @@ describe "Commenting topics from proposals" do
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario "Reply update parent comment responses count", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
comment = create(:comment, commentable: topic)
|
||||
|
||||
login_as(create(:user))
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
Reference in New Issue
Block a user