From 1356ea217b5d306bb4d316aa5b44547d458bd0d6 Mon Sep 17 00:00:00 2001 From: iagirre Date: Wed, 13 Sep 2017 13:30:37 +0200 Subject: [PATCH] Erased extra empty HTML for comments without replies. Added .gitignore rules for Netbeans projects Cambios para hacer commit: modificado: .gitignore modificado: app/assets/javascripts/comments.js.coffee modificado: app/views/comments/_comment.html.erb modificado: spec/features/comments/debates_spec.rb --- .gitignore | 3 +++ app/assets/javascripts/comments.js.coffee | 2 ++ app/views/comments/_comment.html.erb | 2 ++ spec/features/comments/debates_spec.rb | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index a6f2826c3..7bb7a3090 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ public/sitemap.xml public/system/ + +#Netbeans projects files +/nbproject diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index fefe85544..94845ca78 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -5,6 +5,8 @@ App.Comments = this.update_comments_count() add_reply: (parent_id, response_html) -> + if $("##{parent_id} .comment-children").length == 0 + $("##{parent_id}").append("
  • ") $("##{parent_id} .comment-children:first").prepend($(response_html)) this.update_comments_count() diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index c22e7aa19..22b63ce01 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -93,6 +93,7 @@ <% end %> + <%unless child_comments_of(comment).empty?%>
  • + <%end%> <% end %> diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index 76320a848..28166784a 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -33,6 +33,10 @@ feature 'Commenting debates' do expect(page).to have_content second_child.body expect(page).to have_link "Go back to #{debate.title}", href: debate_path(debate) + + expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2) + expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1) + expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) end scenario 'Collapsable comments', :js do