This commit is contained in:
David Gil
2015-08-11 18:05:12 +02:00
parent d86eb9f550
commit 9d2bece0b3
4 changed files with 22 additions and 10 deletions

View File

@@ -4,10 +4,15 @@ App.Comments =
$(response_html).insertAfter($("#js-comment-form-#{parent_id}"))
reset_and_hide_form: (id) ->
form = $("#js-comment-form-#{id}")
form.val('')
form = $("#js-comment-form-#{id} form")
input = form.find("textarea")
input.val('')
form.hide()
reset_form: (id) ->
input = $("#js-comment-form-#{id} form textarea")
input.val('')
toggle_form: (id) ->
$("#js-comment-form-#{id}").toggle()
@@ -16,5 +21,3 @@ App.Comments =
id = $(this).data().id
App.Comments.toggle_form(id)
false

View File

@@ -1,3 +1,9 @@
var parent_id = '<%= dom_id(@parent) %>';
App.Comments.reset_and_hide_form(parent_id);
<% if @parent.is_a?(Debate) -%>
App.Comments.reset_form(parent_id);
<% else -%>
App.Comments.reset_and_hide_form(parent_id);
<% end -%>
App.Comments.add_response(parent_id, "<%= j(render @comment) %>");

View File

@@ -59,6 +59,7 @@ feature 'Comments' do
visit debate_path(debate)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in 'comment_body', with: 'It will be done next week.'
click_button 'Publish reply'
@@ -67,6 +68,8 @@ feature 'Comments' do
within "#comment-#{comment.id}" do
expect(page).to have_content 'It will be done next week.'
end
expect(page).to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
end
scenario "N replies", :js do
@@ -74,13 +77,13 @@ feature 'Comments' do
parent = create(:comment, commentable: debate)
7.times do
create(:comment, commentable: debate).
move_to_child_of(parent)
parent = parent.children.first
create(:comment, commentable: debate).
move_to_child_of(parent)
parent = parent.children.first
end
visit debate_path(debate)
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
end
end
end

View File

@@ -56,4 +56,4 @@ module CommonActions
SimpleCaptcha::SimpleCaptchaData.first.value
end
end
end