Merge pull request #272 from AyuntamientoMadrid/fix-replies

adds comments labels per comment
This commit is contained in:
Enrique García
2015-08-28 15:46:08 +02:00
4 changed files with 19 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
<div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>> <div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>>
<%= form_for [@debate, Comment.new], remote: true do |f| %> <%= form_for [@debate, Comment.new], remote: true do |f| %>
<%= f.text_area :body, label: t("comments.form.leave_comment") %> <%= label_tag "comment-body-#{dom_id(parent)}", t("comments.form.leave_comment") %>
<%= f.text_area :body, id: "comment-body-#{dom_id(parent)}", label: false %>
<%= f.hidden_field :commentable_type, value: parent.class %> <%= f.hidden_field :commentable_type, value: parent.class %>
<%= f.hidden_field :commentable_id, value: parent.id %> <%= f.hidden_field :commentable_id, value: parent.id %>
@@ -8,14 +9,14 @@
<% if can? :comment_as_moderator, @debate %> <% if can? :comment_as_moderator, @debate %>
<div class="right"> <div class="right">
<%= f.check_box :as_moderator, label: false %> <%= f.check_box :as_moderator, id: "comment-as-moderator-#{dom_id(parent)}", label: false %>
<%= f.label :as_moderator, t("comments.form.comment_as_moderator"), class: "checkbox" %> <%= label_tag "comment-as-moderator-#{dom_id(parent)}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
</div> </div>
<% end %> <% end %>
<% if can? :comment_as_administrator, @debate %> <% if can? :comment_as_administrator, @debate %>
<div class="right"> <div class="right">
<%= f.check_box :as_administrator, label: false %> <%= f.check_box :as_administrator, id: "comment-as-administrator-#{dom_id(parent)}",label: false %>
<%= f.label :as_administrator, t("comments.form.comment_as_admin"), class: "checkbox" %> <%= label_tag "comment-as-administrator-#{dom_id(parent)}", t("comments.form.comment_as_admin"), class: "checkbox" %>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>

View File

@@ -1,2 +1,2 @@
var field_with_errors = "#js-comment-form-<%= dom_id(@parent) %> #comment_body"; var field_with_errors = "#js-comment-form-<%= dom_id(@parent) %> #comment-body-<%= dom_id(@parent) %>";
App.Comments.display_error(field_with_errors, "<%= j render('comments/errors') %>"); App.Comments.display_error(field_with_errors, "<%= j render('comments/errors') %>");

View File

@@ -59,7 +59,7 @@ feature 'Comments' do
login_as(user) login_as(user)
visit debate_path(debate) visit debate_path(debate)
fill_in 'comment_body', with: 'Have you thought about...?' fill_in "comment-body-debate_#{debate.id}", with: 'Have you thought about...?'
click_button 'Publish comment' click_button 'Publish comment'
within "#comments" do within "#comments" do
@@ -91,7 +91,7 @@ feature 'Comments' do
click_link "Reply" click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do within "#js-comment-form-comment_#{comment.id}" do
fill_in 'comment_body', with: 'It will be done next week.' fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
click_button 'Publish reply' click_button 'Publish reply'
end end
@@ -178,8 +178,8 @@ feature 'Comments' do
login_as(moderator.user) login_as(moderator.user)
visit debate_path(debate) visit debate_path(debate)
fill_in "comment_body", with: "I am moderating!" fill_in "comment-body-debate_#{debate.id}", with: "I am moderating!"
check "comment_as_moderator" check "comment-as-moderator-debate_#{debate.id}"
click_button "Publish comment" click_button "Publish comment"
within "#comments" do within "#comments" do
@@ -203,8 +203,8 @@ feature 'Comments' do
click_link "Reply" click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment_body", with: "I am moderating!" fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
check "comment_as_moderator" check "comment-as-moderator-comment_#{comment.id}"
click_button 'Publish reply' click_button 'Publish reply'
end end
@@ -237,8 +237,8 @@ feature 'Comments' do
login_as(admin.user) login_as(admin.user)
visit debate_path(debate) visit debate_path(debate)
fill_in "comment_body", with: "I am your Admin!" fill_in "comment-body-debate_#{debate.id}", with: "I am your Admin!"
check "comment_as_administrator" check "comment-as-administrator-debate_#{debate.id}"
click_button "Publish comment" click_button "Publish comment"
within "#comments" do within "#comments" do
@@ -262,8 +262,8 @@ feature 'Comments' do
click_link "Reply" click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment_body", with: "Top of the world!" fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
check "comment_as_administrator" check "comment-as-administrator-comment_#{comment.id}"
click_button 'Publish reply' click_button 'Publish reply'
end end

View File

@@ -30,7 +30,7 @@ module CommonActions
login_as(user2) login_as(user2)
visit debate_path(debate) visit debate_path(debate)
fill_in 'comment_body', with: 'Have you thought about...?' fill_in "comment-body-debate_#{debate.id}", with: 'Have you thought about...?'
click_button 'Publish comment' click_button 'Publish comment'
expect(page).to have_content 'Have you thought about...?' expect(page).to have_content 'Have you thought about...?'
end end
@@ -45,7 +45,7 @@ module CommonActions
click_link "Reply" click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do within "#js-comment-form-comment_#{comment.id}" do
fill_in 'comment_body', with: 'It will be done next week.' fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
click_button 'Publish reply' click_button 'Publish reply'
end end
expect(page).to have_content 'It will be done next week.' expect(page).to have_content 'It will be done next week.'