diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 6b3c9d85f..39721877c 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -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) %>
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 %>
diff --git a/spec/shared/system/notifiable_in_app.rb b/spec/shared/system/notifiable_in_app.rb index c141b98c4..4cbfdb394 100644 --- a/spec/shared/system/notifiable_in_app.rb +++ b/spec/shared/system/notifiable_in_app.rb @@ -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 diff --git a/spec/support/common_actions/notifications.rb b/spec/support/common_actions/notifications.rb index 9dbb38091..60f1673aa 100644 --- a/spec/support/common_actions/notifications.rb +++ b/spec/support/common_actions/notifications.rb @@ -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