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:
Senén Rodero Rodríguez
2020-05-08 07:00:30 +02:00
parent 095abbf9a7
commit 956f002738
12 changed files with 144 additions and 9 deletions

View File

@@ -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)