Merge pull request #4008 from consul/comments

Simplify code to render comments
This commit is contained in:
Javier Martín
2020-05-13 12:38:12 +02:00
committed by GitHub
33 changed files with 288 additions and 303 deletions

View File

@@ -25,7 +25,7 @@ gem "globalize-accessors", "~> 0.2.1"
gem "graphiql-rails", "~> 1.4.1"
gem "graphql", "~> 1.7.8"
gem "groupdate", "~> 3.2.0"
gem "initialjs-rails", "~> 0.2.0.5"
gem "initialjs-rails", "~> 0.2.0.8"
gem "invisible_captcha", "~> 0.10.0"
gem "jquery-fileupload-rails"
gem "jquery-rails", "~> 4.3.3"

View File

@@ -282,7 +282,7 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
ice_nine (0.11.2)
initialjs-rails (0.2.0.5)
initialjs-rails (0.2.0.8)
railties (>= 3.1, < 6.0)
invisible_captcha (0.10.0)
rails (>= 3.2.0)
@@ -642,7 +642,7 @@ DEPENDENCIES
graphql (~> 1.7.8)
groupdate (~> 3.2.0)
i18n-tasks (~> 0.9.29)
initialjs-rails (~> 0.2.0.5)
initialjs-rails (~> 0.2.0.8)
invisible_captcha (~> 0.10.0)
jquery-fileupload-rails
jquery-rails (~> 4.3.3)

View File

@@ -1,15 +1,8 @@
(function() {
"use strict";
App.Comments = {
add_comment: function(parent_id, response_html) {
$(response_html).insertAfter($("#js-comment-form-" + parent_id));
this.update_comments_count();
},
add_reply: function(parent_id, response_html) {
if ($("#" + parent_id + " .comment-children").length === 0) {
$("#" + parent_id).append("<li><ul id='" + parent_id + "_children' class='no-bullet comment-children'></ul></li>");
}
$("#" + parent_id + " .comment-children:first").prepend($(response_html));
add_comment: function(parent_selector, response_html) {
$(parent_selector + " .comment-list:first").prepend($(response_html));
this.update_comments_count();
},
update_comments_count: function() {
@@ -24,24 +17,19 @@
display_error: function(field_with_errors, error_html) {
$(error_html).insertAfter($("" + field_with_errors));
},
reset_and_hide_form: function(id) {
var form_container, input;
form_container = $("#js-comment-form-" + id);
input = form_container.find("form textarea");
input.val("");
form_container.hide();
},
reset_form: function(id) {
var input;
input = $("#js-comment-form-" + id + " form textarea");
input.val("");
reset_form: function(parent_selector) {
var form_container;
form_container = $(parent_selector + " .comment-form:first");
form_container.find("textarea").val("");
if (parent_selector !== "") {
form_container.hide();
}
},
toggle_form: function(id) {
$("#js-comment-form-" + id).toggle();
},
toggle_arrow: function(id) {
$("span#" + id + "_arrow").toggleClass("fa-minus-square").toggleClass("fa-plus-square");
},
initialize: function() {
$("body").on("click", ".js-add-comment-link", function() {
App.Comments.toggle_form($(this).data().id);
@@ -49,10 +37,8 @@
});
$("body").on("click", ".js-toggle-children", function() {
var children_container_id;
children_container_id = ($(this).data().id) + "_children";
$("#" + children_container_id).toggle("slow");
App.Comments.toggle_arrow(children_container_id);
$(this).closest(".comment").find(".comment-list:first").toggle("slow");
$(this).children(".far").toggleClass("fa-minus-square fa-plus-square");
$(this).children(".js-child-toggle").toggle();
return false;
});

View File

@@ -2084,6 +2084,7 @@ table {
}
.comment {
line-height: $list-lineheight;
margin: $line-height / 4 0;
position: relative;
@@ -2171,12 +2172,24 @@ table {
}
}
.comment-children {
border-left: 1px dashed $border;
display: inline-block;
margin-left: rem-calc(16);
padding-left: rem-calc(8);
width: 100%;
.comment-list {
margin: $line-height / 4 0;
.comment-list {
border-left: 1px dashed $border;
display: inline-block;
padding-left: rem-calc(8);
width: 100%;
}
.comment-form {
display: none;
}
&:empty {
display: none;
}
}
.comment-info {

View File

@@ -19,7 +19,6 @@
<div class="tabs-content" data-tabs-content="investments_tabs">
<div class="tabs-panel is-active" id="tab-comments">
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: false %>
</div>

View File

@@ -1,12 +1,7 @@
<% comment_flags ||= @comment_flags %>
<% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_votes = local_assigns.fetch(:allow_votes, true) %>
<% allow_actions = local_assigns.fetch(:allow_actions, true) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% admin_layout = local_assigns.fetch(:admin_layout, false) %>
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags), (admin_layout if admin_layout)] do %>
<ul id="<%= dom_id(comment) %>" class="comment no-bullet small-12">
<li class="comment-body">
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author] do %>
<div id="<%= dom_id(comment) %>" class="comment small-12">
<div class="comment-body">
<% if comment.hidden? || comment.user.hidden? %>
<% if comment.children.size > 0 %>
<div class="callout secondary">
@@ -33,7 +28,7 @@
<% if comment.as_administrator? %>
<span class="user-name">
<%= t("comments.comment.admin") %>
<% if admin_layout %>
<% if valuation %>
<%= Administrator.find(comment.administrator_id).description_or_name %>
<% else %>
#<%= comment.administrator_id %>
@@ -84,17 +79,15 @@
</div>
<div id="<%= dom_id(comment) %>_reply" class="reply">
<% if allow_votes %>
<% unless valuation %>
<div id="<%= dom_id(comment) %>_votes" class="comment-votes float-right">
<%= render "comments/votes", comment: comment %>
</div>
<% end %>
<% if comment.children.size > 0 %>
<%= link_to "", class: "js-toggle-children relative", data: { "id": "#{dom_id(comment)}" } do %>
<span class="show-for-sr js-child-toggle" style="display: none;"><%= t("shared.show") %></span>
<span class="show-for-sr js-child-toggle"><%= t("shared.hide") %></span>
<span id="<%= dom_id(comment) %>_children_arrow" class="far fa-minus-square"></span>
<%= link_to "", class: "js-toggle-children relative" do %>
<span class="far fa-minus-square"></span>
<span class="js-child-toggle" style="display: none;"><%= t("comments.comment.responses_show", count: comment.children.size) %></span>
<span class="js-child-toggle"><%= t("comments.comment.responses_collapse", count: comment.children.size) %></span>
<% end %>
@@ -107,34 +100,20 @@
<%= link_to(comment_link_text(comment), "",
class: "js-add-comment-link", data: { "id": dom_id(comment) }) %>
<% if allow_actions %>
<% unless valuation %>
<%= render "comments/actions", { comment: comment } %>
<% end %>
<% if allow_comments %>
<% if !valuation || can?(:comment_valuation, comment.commentable) %>
<%= render "comments/form", { commentable: comment.commentable,
parent_id: comment.id,
toggeable: true,
valuation: valuation } %>
<% end %>
<% end %>
</div>
<% end %>
</li>
<% unless child_comments_of(comment).empty? %>
<li>
<ul id="<%= dom_id(comment) %>_children" class="no-bullet comment-children">
<% child_comments_of(comment).each do |child| %>
<li>
<%= render "comments/comment", { comment: child,
valuation: valuation,
allow_votes: allow_votes,
allow_actions: allow_actions,
allow_comments: allow_comments } %>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>
</div>
<%= render "comments/comment_list", comments: child_comments_of(comment), valuation: valuation %>
</div>
<% end %>

View File

@@ -0,0 +1,7 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<%= tag.ul class: "no-bullet comment-list" do %>
<% comments.each do |comment| %>
<%= tag.li render("comments/comment", { comment: comment, valuation: valuation }) %>
<% end %>
<% end %>

View File

@@ -1,8 +1,6 @@
<% commentable = comment_tree.commentable %>
<% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% admin_layout = local_assigns.fetch(:admin_layout, false) %>
<% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags, admin_layout] do %>
<% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count] do %>
<section class="expanded comments">
<div class="row">
<div id="comments" class="small-12 column">
@@ -26,10 +24,9 @@
<div data-alert class="callout primary">
<%= sanitize(t("comments.verified_only", verify_account: link_to_verify_account)) %>
</div>
<% elsif allow_comments %>
<% elsif !valuation || can?(:comment_valuation, commentable) %>
<%= render "comments/form", { commentable: commentable,
parent_id: nil,
toggeable: false,
valuation: valuation } %>
<% end %>
<% else %>
@@ -37,15 +34,7 @@
<%= render "shared/login_to_comment" %>
<% end %>
<% comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", { comment: comment,
comment_flags: comment_flags,
valuation: valuation,
allow_votes: !valuation,
allow_actions: !valuation,
allow_comments: allow_comments,
admin_layout: admin_layout } %>
<% end %>
<%= render "comments/comment_list", comments: comment_tree.root_comments, valuation: valuation %>
<%= paginate comment_tree.root_comments %>
</div>
</div>

View File

@@ -1,33 +0,0 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@investment), @comment_tree.comments, @comment_tree.comment_authors, @investment.comments_count, @comment_flags] do %>
<section class="expanded comments">
<div class="row">
<div id="comments" class="small-12 column">
<h2>
<%= t("debates.show.comments_title") %>
<span class="js-comments-count">(<%= @investment.comments_count %>)</span>
</h2>
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? && allow_comments %>
<%= render "comments/form", { commentable: @investment,
parent_id: nil,
toggeable: false,
valuation: valuation } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", { comment: comment,
valuation: valuation,
allow_comments: allow_comments } %>
<% end %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>
</section>
<% end %>

View File

@@ -1,19 +1,19 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<% 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| %>
<div id="js-comment-form-<%= css_id %>" class="comment-form">
<%= 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">

View File

@@ -1,11 +1,8 @@
var comment_html = "<%= j(render @comment) %>"
<% if @comment.root? -%>
var commentable_id = "<%= dom_id(@commentable) %>";
App.Comments.reset_form(commentable_id);
App.Comments.add_comment(commentable_id, comment_html);
var parent_id = "";
<% else -%>
var parent_id = "<%= "comment_#{@comment.parent_id}" %>";
App.Comments.reset_and_hide_form(parent_id);
App.Comments.add_reply(parent_id, comment_html);
var parent_id = "#" + "<%= "comment_#{@comment.parent_id}" %>";
<% end -%>
App.Comments.reset_form(parent_id);
App.Comments.add_comment(parent_id, "<li><%= j(render @comment) %></li>");

View File

@@ -1,4 +1,4 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@debate), @comment_tree.comments, @comment_tree.comment_authors, @debate.comments_count, @comment_flags] do %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@debate), @comment_tree.comments, @comment_tree.comment_authors, @debate.comments_count] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<h3>
@@ -9,15 +9,13 @@
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @debate, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @debate, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", comment: comment %>
<% end %>
<%= render "comments/comment_list", comments: @comment_tree.root_comments %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>

View File

@@ -43,7 +43,6 @@
</div>
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: true %>
</div>
</div>

View File

@@ -1,18 +1,16 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count, @comment_flags] do %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", comment: comment %>
<% end %>
<%= render "comments/comment_list", comments: @comment_tree.root_comments %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>

View File

@@ -43,6 +43,5 @@
</div>
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: true %>
</section>

View File

@@ -1,18 +1,16 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@poll), @comment_tree.comments, @comment_tree.comment_authors, @poll.comments_count, @comment_flags] do %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@poll), @comment_tree.comments, @comment_tree.comment_authors, @poll.comments_count] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @poll, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @poll, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", comment: comment %>
<% end %>
<%= render "comments/comment_list", comments: @comment_tree.root_comments %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>

View File

@@ -1,18 +1,16 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count, @comment_flags] do %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", comment: comment %>
<% end %>
<%= render "comments/comment_list", comments: @comment_tree.root_comments %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>

View File

@@ -1,17 +1,14 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@topic), @comment_tree.comments, @comment_tree.comment_authors, @topic.comments_count, @comment_flags] do %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@topic), @comment_tree.comments, @comment_tree.comment_authors, @topic.comments_count] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render "comments/comment", comment: comment %>
<% end %>
<%= render "comments/comment_list", comments: @comment_tree.root_comments %>
<%= paginate @comment_tree.root_comments %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @topic, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @topic, parent_id: nil } %>
<% else %>
<%= render "shared/login_to_comment" %>
<% end %>

View File

@@ -1,9 +1,6 @@
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
<% unless @comment_tree.nil? %>
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: false,
valuation: true,
allow_comments: can?(:comment_valuation, @investment),
admin_layout: true %>
valuation: true %>
<% end %>

View File

@@ -723,7 +723,6 @@ en:
notice: "Now you are following this citizen proposal! <br> We will notify you of changes as they occur so that you are up-to-date."
destroy:
notice: "You have stopped following this citizen proposal! <br> You will no longer receive notifications related to this proposal."
hide: Hide
print:
print_button: Print this info
search: Search

View File

@@ -721,7 +721,6 @@ es:
notice: "¡Ahora estás siguiendo esta propuesta ciudadana! <br> Te notificaremos los cambios a medida que se produzcan para que estés al día."
destroy:
notice: "¡Has dejado de seguir esta propuesta ciudadana! <br> Ya no recibirás más notificaciones relacionadas con esta propuesta."
hide: Ocultar
print:
print_button: Imprimir esta información
search: Buscar

View File

@@ -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
@@ -53,7 +53,7 @@ shared_examples "notifiable in-app" do |factory_name|
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I replied to your comment"
fill_in comment_body(notifiable), with: "I replied to your comment"
click_button "Publish reply"
end
@@ -79,7 +79,7 @@ shared_examples "notifiable in-app" do |factory_name|
within("#comment_#{comment.id}_reply") { click_link "Reply" }
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Reply number #{n}"
fill_in comment_body(notifiable), with: "Reply number #{n}"
click_button "Publish reply"
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
@@ -121,7 +121,7 @@ shared_examples "notifiable in-app" do |factory_name|
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I replied to my own comment"
fill_in comment_body(notifiable), with: "I replied to my own comment"
click_button "Publish reply"
end

View File

@@ -17,7 +17,7 @@ module Comments
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
expect(page).to have_content "It will be done next week."

View File

@@ -10,7 +10,19 @@ module Notifications
end
def comment_body(resource)
"comment-body-#{resource.class.name.parameterize(separator: "_").to_sym}_#{resource.id}"
if resource.class.name == "Legislation::Question"
"Leave your answer"
else
"Leave your comment"
end
end
def submit_comment_text(resource)
if resource.class.name == "Legislation::Question"
"Publish answer"
else
"Publish comment"
end
end
def create_proposal_notification(proposal)

View File

@@ -23,22 +23,22 @@ describe "Commenting Budget::Investments" do
end
scenario "Show" do
parent_comment = create(:comment, commentable: investment)
first_child = create(:comment, commentable: investment, parent: parent_comment)
second_child = create(:comment, commentable: investment, parent: parent_comment)
parent_comment = create(:comment, commentable: investment, body: "Parent")
create(:comment, commentable: investment, parent: parent_comment, body: "First subcomment")
create(:comment, commentable: investment, parent: parent_comment, body: "Last subcomment")
visit comment_path(parent_comment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content parent_comment.body
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_content "Parent"
expect(page).to have_content "First subcomment"
expect(page).to have_content "Last subcomment"
expect(page).to have_link "Go back to #{investment.title}", href: budget_investment_path(investment.budget, investment)
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
within ".comment", text: "Parent" do
expect(page).to have_selector(".comment", count: 2)
end
end
scenario "Link to comment show" do
@@ -66,20 +66,26 @@ describe "Commenting Budget::Investments" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -193,7 +199,7 @@ describe "Commenting Budget::Investments" do
login_as(user)
visit budget_investment_path(investment.budget, investment)
fill_in "comment-body-budget_investment_#{investment.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#tab-comments-label" do
@@ -225,7 +231,7 @@ describe "Commenting Budget::Investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -328,7 +334,7 @@ describe "Commenting Budget::Investments" do
login_as(moderator.user)
visit budget_investment_path(investment.budget, investment)
fill_in "comment-body-budget_investment_#{investment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-budget_investment_#{investment.id}"
click_button "Publish comment"
@@ -352,7 +358,7 @@ describe "Commenting Budget::Investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -385,7 +391,7 @@ describe "Commenting Budget::Investments" do
login_as(admin.user)
visit budget_investment_path(investment.budget, investment)
fill_in "comment-body-budget_investment_#{investment.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-budget_investment_#{investment.id}"
click_button "Publish comment"
@@ -404,7 +410,7 @@ describe "Commenting Budget::Investments" do
visit admin_budget_budget_investment_path(investment.budget, investment)
fill_in "comment-body-budget_investment_#{investment.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-budget_investment_#{investment.id}"
click_button "Publish comment"
@@ -428,7 +434,7 @@ describe "Commenting Budget::Investments" do
login_as(admin.user)
visit admin_budget_budget_investment_path(investment.budget, investment)
fill_in "comment-body-budget_investment_#{investment.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-budget_investment_#{investment.id}"
click_button "Publish comment"
@@ -452,7 +458,7 @@ describe "Commenting Budget::Investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -61,7 +61,7 @@ describe "Internal valuation comments on Budget::Investments" do
scenario "Collapsable comments", :js do
parent_comment = create(:comment, :valuation, author: valuator_user, body: "Main comment",
commentable: investment)
child_comment = create(:comment, :valuation, author: valuator_user, body: "First child",
child_comment = create(:comment, :valuation, author: valuator_user, body: "First subcomment",
commentable: investment, parent: parent_comment)
grandchild_comment = create(:comment, :valuation, author: valuator_user,
parent: child_comment,
@@ -73,20 +73,26 @@ describe "Internal valuation comments on Budget::Investments" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")

View File

@@ -20,22 +20,22 @@ describe "Commenting debates" do
end
scenario "Show" do
parent_comment = create(:comment, commentable: debate)
first_child = create(:comment, commentable: debate, parent: parent_comment)
second_child = create(:comment, commentable: debate, parent: parent_comment)
parent_comment = create(:comment, commentable: debate, body: "Parent")
create(:comment, commentable: debate, parent: parent_comment, body: "First subcomment")
create(:comment, commentable: debate, parent: parent_comment, body: "Last subcomment")
visit comment_path(parent_comment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content parent_comment.body
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_content "Parent"
expect(page).to have_content "First subcomment"
expect(page).to have_content "Last subcomment"
expect(page).to have_link "Go back to #{debate.title}", href: debate_path(debate)
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
within ".comment", text: "Parent" do
expect(page).to have_selector(".comment", count: 2)
end
end
scenario "Link to comment show" do
@@ -63,20 +63,26 @@ describe "Commenting debates" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -210,7 +216,7 @@ describe "Commenting debates" do
login_as(user)
visit debate_path(debate)
fill_in "comment-body-debate_#{debate.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -239,7 +245,7 @@ describe "Commenting debates" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -365,7 +371,7 @@ describe "Commenting debates" do
login_as(user)
visit debate_path(debate)
fill_in "comment-body-debate_#{debate.id}", with: "Testing submit button!"
fill_in "Leave your comment", with: "Testing submit button!"
click_button "Publish comment"
# The button"s text should now be "..."
@@ -382,7 +388,7 @@ describe "Commenting debates" do
login_as(moderator.user)
visit debate_path(debate)
fill_in "comment-body-debate_#{debate.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-debate_#{debate.id}"
click_button "Publish comment"
@@ -406,7 +412,7 @@ describe "Commenting debates" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -438,7 +444,7 @@ describe "Commenting debates" do
login_as(admin.user)
visit debate_path(debate)
fill_in "comment-body-debate_#{debate.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-debate_#{debate.id}"
click_button "Publish comment"
@@ -462,7 +468,7 @@ describe "Commenting debates" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -22,25 +22,25 @@ describe "Commenting legislation questions" do
end
scenario "Show" do
parent_comment = create(:comment, commentable: legislation_annotation)
first_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
second_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
href = legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
parent_comment = create(:comment, commentable: legislation_annotation, body: "Parent")
create(:comment, commentable: legislation_annotation, parent: parent_comment, body: "First subcomment")
create(:comment, commentable: legislation_annotation, parent: parent_comment, body: "Last subcomment")
visit comment_path(parent_comment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content parent_comment.body
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_content "Parent"
expect(page).to have_content "First subcomment"
expect(page).to have_content "Last subcomment"
expect(page).to have_link "Go back to #{legislation_annotation.title}", href: href
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
within ".comment", text: "Parent" do
expect(page).to have_selector(".comment", count: 2)
end
end
scenario "Link to comment show" do
@@ -71,20 +71,26 @@ describe "Commenting legislation questions" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: parent_comment.body do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -227,7 +233,7 @@ describe "Commenting legislation questions" do
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -261,7 +267,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -378,7 +384,7 @@ describe "Commenting legislation questions" do
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "Testing submit button!"
fill_in "Leave your comment", with: "Testing submit button!"
click_button "Publish comment"
# The button's text should now be "..."
@@ -397,7 +403,7 @@ describe "Commenting legislation questions" do
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-legislation_annotation_#{legislation_annotation.id}"
click_button "Publish comment"
@@ -424,7 +430,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -460,7 +466,7 @@ describe "Commenting legislation questions" do
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-legislation_annotation_#{legislation_annotation.id}"
click_button "Publish comment"
@@ -487,7 +493,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -661,7 +667,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "replying in single annotation thread"
fill_in "Leave your comment", with: "replying in single annotation thread"
click_button "Publish reply"
end
@@ -700,7 +706,7 @@ describe "Commenting legislation questions" do
end
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "replying in multiple annotation thread"
fill_in "Leave your comment", with: "replying in multiple annotation thread"
click_button "Publish reply"
end

View File

@@ -25,23 +25,23 @@ describe "Commenting legislation questions" do
end
scenario "Show" do
parent_comment = create(:comment, commentable: legislation_question)
first_child = create(:comment, commentable: legislation_question, parent: parent_comment)
second_child = create(:comment, commentable: legislation_question, parent: parent_comment)
href = legislation_process_question_path(legislation_question.process, legislation_question)
parent_comment = create(:comment, commentable: legislation_question, body: "Parent")
create(:comment, commentable: legislation_question, parent: parent_comment, body: "First subcomment")
create(:comment, commentable: legislation_question, parent: parent_comment, body: "Last subcomment")
visit comment_path(parent_comment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content parent_comment.body
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_content "Parent"
expect(page).to have_content "First subcomment"
expect(page).to have_content "Last subcomment"
expect(page).to have_link "Go back to #{legislation_question.title}", href: href
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
within ".comment", text: "Parent" do
expect(page).to have_selector(".comment", count: 2)
end
end
scenario "Link to comment show" do
@@ -69,20 +69,26 @@ describe "Commenting legislation questions" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -196,7 +202,7 @@ describe "Commenting legislation questions" do
login_as(user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "Have you thought about...?"
fill_in "Leave your answer", with: "Have you thought about...?"
click_button "Publish answer"
within "#comments" do
@@ -243,7 +249,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your answer", with: "It will be done next week."
click_button "Publish reply"
end
@@ -342,7 +348,7 @@ describe "Commenting legislation questions" do
login_as(user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "Testing submit button!"
fill_in "Leave your answer", with: "Testing submit button!"
click_button "Publish answer"
# The button's text should now be "..."
@@ -359,7 +365,7 @@ describe "Commenting legislation questions" do
login_as(moderator.user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "I am moderating!"
fill_in "Leave your answer", with: "I am moderating!"
check "comment-as-moderator-legislation_question_#{legislation_question.id}"
click_button "Publish answer"
@@ -383,7 +389,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your answer", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -415,7 +421,7 @@ describe "Commenting legislation questions" do
login_as(admin.user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "I am your Admin!"
fill_in "Leave your answer", with: "I am your Admin!"
check "comment-as-administrator-legislation_question_#{legislation_question.id}"
click_button "Publish answer"
@@ -439,7 +445,7 @@ describe "Commenting legislation questions" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your answer", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -64,20 +64,26 @@ describe "Commenting polls" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -191,7 +197,7 @@ describe "Commenting polls" do
login_as(user)
visit poll_path(poll)
fill_in "comment-body-poll_#{poll.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -223,7 +229,7 @@ describe "Commenting polls" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -334,7 +340,7 @@ describe "Commenting polls" do
login_as(moderator.user)
visit poll_path(poll)
fill_in "comment-body-poll_#{poll.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-poll_#{poll.id}"
click_button "Publish comment"
@@ -360,7 +366,7 @@ describe "Commenting polls" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -396,7 +402,7 @@ describe "Commenting polls" do
login_as(admin.user)
visit poll_path(poll)
fill_in "comment-body-poll_#{poll.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-poll_#{poll.id}"
click_button "Publish comment"
@@ -422,7 +428,7 @@ describe "Commenting polls" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -20,21 +20,21 @@ describe "Commenting proposals" do
end
scenario "Show" do
parent_comment = create(:comment, commentable: proposal)
first_child = create(:comment, commentable: proposal, parent: parent_comment)
second_child = create(:comment, commentable: proposal, parent: parent_comment)
parent_comment = create(:comment, commentable: proposal, body: "Parent")
create(:comment, commentable: proposal, parent: parent_comment, body: "First subcomment")
create(:comment, commentable: proposal, parent: parent_comment, body: "Last subcomment")
visit comment_path(parent_comment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content parent_comment.body
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_content "Parent"
expect(page).to have_content "First subcomment"
expect(page).to have_content "Last subcomment"
expect(page).to have_link "Go back to #{proposal.title}", href: proposal_path(proposal)
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
within ".comment", text: "Parent" do
expect(page).to have_selector(".comment", count: 2)
end
end
scenario "Link to comment show" do
@@ -62,20 +62,26 @@ describe "Commenting proposals" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -189,7 +195,7 @@ describe "Commenting proposals" do
login_as(user)
visit proposal_path(proposal)
fill_in "comment-body-proposal_#{proposal.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -221,7 +227,7 @@ describe "Commenting proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -324,7 +330,7 @@ describe "Commenting proposals" do
login_as(moderator.user)
visit proposal_path(proposal)
fill_in "comment-body-proposal_#{proposal.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-proposal_#{proposal.id}"
click_button "Publish comment"
@@ -348,7 +354,7 @@ describe "Commenting proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -380,7 +386,7 @@ describe "Commenting proposals" do
login_as(admin.user)
visit proposal_path(proposal)
fill_in "comment-body-proposal_#{proposal.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-proposal_#{proposal.id}"
click_button "Publish comment"
@@ -404,7 +410,7 @@ describe "Commenting proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -67,20 +67,26 @@ describe "Commenting topics from proposals" do
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("1 response (collapse)")
expect(page).to have_content("1 response (show)")
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).to have_content("1 response (show)")
@@ -210,7 +216,7 @@ describe "Commenting topics from proposals" do
login_as(user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -247,7 +253,7 @@ describe "Commenting topics from proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -363,7 +369,7 @@ describe "Commenting topics from proposals" do
login_as(moderator.user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-topic_#{topic.id}"
click_button "Publish comment"
@@ -389,7 +395,7 @@ describe "Commenting topics from proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -425,7 +431,7 @@ describe "Commenting topics from proposals" do
login_as(admin.user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-topic_#{topic.id}"
click_button "Publish comment"
@@ -451,7 +457,7 @@ describe "Commenting topics from proposals" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -625,17 +631,23 @@ describe "Commenting topics from budget investments" do
expect(page).to have_css(".comment", count: 3)
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).not_to have_content grandchild_comment.body
find("#comment_#{child_comment.id}_children_arrow").click
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (show)"
end
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content grandchild_comment.body
find("#comment_#{parent_comment.id}_children_arrow").click
within ".comment", text: "Main comment" do
click_link text: "1 response (collapse)", match: :first
end
expect(page).to have_css(".comment", count: 1)
expect(page).not_to have_content child_comment.body
@@ -764,7 +776,7 @@ describe "Commenting topics from budget investments" do
login_as(user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "Have you thought about...?"
fill_in "Leave your comment", with: "Have you thought about...?"
click_button "Publish comment"
within "#comments" do
@@ -801,7 +813,7 @@ describe "Commenting topics from budget investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
@@ -917,7 +929,7 @@ describe "Commenting topics from budget investments" do
login_as(moderator.user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-topic_#{topic.id}"
click_button "Publish comment"
@@ -943,7 +955,7 @@ describe "Commenting topics from budget investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
fill_in "Leave your comment", with: "I am moderating!"
check "comment-as-moderator-comment_#{comment.id}"
click_button "Publish reply"
end
@@ -979,7 +991,7 @@ describe "Commenting topics from budget investments" do
login_as(admin.user)
visit community_topic_path(community, topic)
fill_in "comment-body-topic_#{topic.id}", with: "I am your Admin!"
fill_in "Leave your comment", with: "I am your Admin!"
check "comment-as-administrator-topic_#{topic.id}"
click_button "Publish comment"
@@ -1005,7 +1017,7 @@ describe "Commenting topics from budget investments" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
fill_in "Leave your comment", with: "Top of the world!"
check "comment-as-administrator-comment_#{comment.id}"
click_button "Publish reply"
end

View File

@@ -443,7 +443,7 @@ describe "Emails" do
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end