Fix duplicate HTML IDs in comment forms
Since there were many on the page, the resulting HTML was invalid.
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
<% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable), valuation] do %>
|
||||
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
|
||||
<div id="js-comment-form-<%= css_id %>" <%= raw("style='display:none'") if toggeable %> class="comment-form">
|
||||
<%= form_for Comment.new, remote: true do |f| %>
|
||||
<%= form_for Comment.new, remote: true, html: { id: "new_comment_#{css_id}" } do |f| %>
|
||||
<%= f.text_area :body,
|
||||
id: "comment-body-#{css_id}",
|
||||
maxlength: Comment.body_max_length,
|
||||
label: leave_comment_text(commentable) %>
|
||||
|
||||
<%= f.hidden_field :commentable_type, value: commentable.class.name %>
|
||||
<%= f.hidden_field :commentable_id, value: commentable.id %>
|
||||
<%= f.hidden_field :parent_id, value: parent_id %>
|
||||
<%= f.hidden_field :valuation, value: valuation %>
|
||||
<%= f.hidden_field :commentable_type, value: commentable.class.name, id: "comment_commentable_type_#{css_id}" %>
|
||||
<%= f.hidden_field :commentable_id, value: commentable.id, id: "comment_commentable_id_#{css_id}" %>
|
||||
<%= f.hidden_field :parent_id, value: parent_id, id: "comment_parent_id_#{css_id}" %>
|
||||
<%= f.hidden_field :valuation, value: valuation, id: "comment_valuation_#{css_id}" %>
|
||||
|
||||
<%= f.submit comment_button_text(parent_id, commentable), class: "button", id: "publish_comment" %>
|
||||
<%= f.submit comment_button_text(parent_id, commentable), class: "button", id: "publish_comment_#{css_id}" %>
|
||||
|
||||
<% if can? :comment_as_moderator, commentable %>
|
||||
<div class="float-right">
|
||||
|
||||
@@ -30,7 +30,7 @@ shared_examples "notifiable in-app" do |factory_name|
|
||||
visit path_for(notifiable)
|
||||
|
||||
fill_in comment_body(notifiable), with: "Number #{n + 1} is the best!"
|
||||
click_button "publish_comment"
|
||||
click_button submit_comment_text(notifiable)
|
||||
within "#comments" do
|
||||
expect(page).to have_content "Number #{n + 1} is the best!"
|
||||
end
|
||||
@@ -102,7 +102,7 @@ shared_examples "notifiable in-app" do |factory_name|
|
||||
visit path_for(notifiable)
|
||||
|
||||
fill_in comment_body(notifiable), with: "I commented on my own notifiable"
|
||||
click_button "publish_comment"
|
||||
click_button submit_comment_text(notifiable)
|
||||
within "#comments" do
|
||||
expect(page).to have_content "I commented on my own notifiable"
|
||||
end
|
||||
|
||||
@@ -13,6 +13,14 @@ module Notifications
|
||||
"comment-body-#{resource.class.name.parameterize(separator: "_").to_sym}_#{resource.id}"
|
||||
end
|
||||
|
||||
def submit_comment_text(resource)
|
||||
if resource.class.name == "Legislation::Question"
|
||||
"Publish answer"
|
||||
else
|
||||
"Publish comment"
|
||||
end
|
||||
end
|
||||
|
||||
def create_proposal_notification(proposal)
|
||||
login_as(proposal.author)
|
||||
visit root_path
|
||||
|
||||
Reference in New Issue
Block a user