refactors duplicate form id scenario [#21]

This commit is contained in:
rgarcia
2015-07-27 22:50:38 +02:00
parent dea2964f08
commit baaf9cac93
3 changed files with 6 additions and 7 deletions

View File

@@ -1,13 +1,12 @@
jQuery ->
toggle_comment = (id, klass) ->
$("#js-comment-form-#{id}-#{klass}").toggle()
toggle_comment = (id) ->
$("#js-comment-form-#{id}").toggle()
ready = ->
$('.js-add-comment-link').click ->
id = $(this).data().id
klass = $(this).data().klass
toggle_comment(id, klass)
toggle_comment(id)
false
$(document).ready(ready)

View File

@@ -1,6 +1,6 @@
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': parent.id, 'klass': parent.class.to_s } %>
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)} %>
<div id="js-comment-form-<%= parent.id %>-<%= parent.class.to_s %>" style="display:none">
<div id="js-comment-form-<%= dom_id(parent) %>" style="display:none">
<%= form_for [@debate, Comment.new] do |f| %>
<%= f.text_area :body %>
<%= f.hidden_field :commentable_type, value: parent.class %>

View File

@@ -48,7 +48,7 @@ feature 'Comments' do
visit debate_path(debate)
click_link "Responder"
within "#js-comment-form-#{comment.id}-Comment" do
within "#js-comment-form-comment_#{comment.id}" do
fill_in 'comment_body', with: 'La semana que viene está hecho.'
click_button 'Publicar respuesta'
end