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

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