@@ -8,7 +8,9 @@
|
|||||||
<%= comment.user.name %> • <%= time_ago_in_words(comment.created_at) %>
|
<%= comment.user.name %> • <%= time_ago_in_words(comment.created_at) %>
|
||||||
</span>
|
</span>
|
||||||
<p><%= comment.body %></p>
|
<p><%= comment.body %></p>
|
||||||
<p class="reply"><%= render 'comments/form', parent: comment %></p>
|
<% if user_signed_in? %>
|
||||||
|
<p class="reply"><%= render 'comments/form', {parent: comment, toggeable: true} %></p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="comment-children">
|
<div class="comment-children">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)} %>
|
<%= link_to(comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)}) if toggeable %>
|
||||||
|
|
||||||
<div id="js-comment-form-<%= dom_id(parent) %>" style="display:none">
|
<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 %>
|
<%= f.text_area :body %>
|
||||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||||
|
|||||||
@@ -13,7 +13,11 @@
|
|||||||
<div id="votes" class="small-12 medium-3 column votes">
|
<div id="votes" class="small-12 medium-3 column votes">
|
||||||
<%= render 'votes/votes' %>
|
<%= render 'votes/votes' %>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
<% if user_signed_in? %>
|
||||||
<%= link_to t("debates.show.leave_comment"), "#comments", class: "leave-comment" %>
|
<%= link_to t("debates.show.leave_comment"), "#comments", class: "leave-comment" %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to t("debates.show.login_to_comment"), new_user_session_path, class: "leave-comment" %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,10 +27,12 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="comments" class="small-12 column">
|
<div id="comments" class="small-12 column">
|
||||||
<h2><%= t("debates.show.comments") %></h2>
|
<h2><%= t("debates.show.comments") %></h2>
|
||||||
|
<% if user_signed_in? %>
|
||||||
<div>
|
<div>
|
||||||
<%= t("debates.show.leave_comment") %>
|
<%= t("debates.show.leave_comment") %>
|
||||||
<%= render 'comments/form', parent: @debate %>
|
<%= render 'comments/form', {parent: @debate, toggeable: false} %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
<%= render @debate.root_comments %>
|
<%= render @debate.root_comments %>
|
||||||
</div>
|
</div>
|
||||||
<% if current_user && @debate.editable_by?(current_user) %>
|
<% if current_user && @debate.editable_by?(current_user) %>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ en:
|
|||||||
comment: Comment
|
comment: Comment
|
||||||
comments: Comments
|
comments: Comments
|
||||||
leave_comment: Write a comment
|
leave_comment: Write a comment
|
||||||
|
login_to_comment: Log in to participate
|
||||||
edit_debate_link: Edit
|
edit_debate_link: Edit
|
||||||
edit:
|
edit:
|
||||||
editing: Edit debate
|
editing: Edit debate
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ es:
|
|||||||
comment: Comentario
|
comment: Comentario
|
||||||
comments: Comentarios
|
comments: Comentarios
|
||||||
leave_comment: Deja tu comentario
|
leave_comment: Deja tu comentario
|
||||||
|
login_to_comment: Entra para participar
|
||||||
edit_debate_link: Editar
|
edit_debate_link: Editar
|
||||||
edit:
|
edit:
|
||||||
editing: Editar debate
|
editing: Editar debate
|
||||||
|
|||||||
@@ -19,6 +19,21 @@ feature 'Comments' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature 'Not logged user' do
|
||||||
|
scenario 'can not see comments forms' do
|
||||||
|
debate = create(:debate)
|
||||||
|
create(:comment, commentable: debate)
|
||||||
|
visit debate_path(debate)
|
||||||
|
|
||||||
|
expect(page).to have_content 'Log in to participate'
|
||||||
|
within ('#comments') do
|
||||||
|
expect(page).to_not have_content 'Write a comment'
|
||||||
|
expect(page).to_not have_content 'Reply'
|
||||||
|
expect(page).to_not have_css('form')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'Create', :js do
|
scenario 'Create', :js do
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
@@ -26,8 +41,6 @@ feature 'Comments' do
|
|||||||
login_as(user)
|
login_as(user)
|
||||||
visit debate_path(debate)
|
visit debate_path(debate)
|
||||||
|
|
||||||
click_on 'Comment'
|
|
||||||
|
|
||||||
fill_in 'comment_body', with: '¿Has pensado en esto...?'
|
fill_in 'comment_body', with: '¿Has pensado en esto...?'
|
||||||
click_button 'Publish comment'
|
click_button 'Publish comment'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user