From 413a034e23259ce8d33fb0fb3ac6fb2fbd4f0dcc Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Thu, 27 Aug 2015 20:21:26 +0200 Subject: [PATCH 1/3] Adds styles for deleted comments --- app/assets/stylesheets/debates.scss | 8 ++++++++ app/assets/stylesheets/participacion.scss | 4 ++++ app/assets/stylesheets/variables.scss | 1 + app/views/comments/_comment.html.erb | 15 +++++++-------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/debates.scss b/app/assets/stylesheets/debates.scss index 641e7ccff..5017837bc 100644 --- a/app/assets/stylesheets/debates.scss +++ b/app/assets/stylesheets/debates.scss @@ -574,6 +574,8 @@ padding: rem-calc(6) rem-calc(12); } + + &.is-admin { background: $comment-admin; padding: rem-calc(6) rem-calc(12); @@ -585,6 +587,12 @@ } } + .is-deleted { + background: $deleted; + margin-left: rem-calc(42); + padding: rem-calc(6) rem-calc(12); + } + .comment-children { border-left: 1px dashed $border; margin-left: rem-calc(42); diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index 116b57ff8..68b236781 100644 --- a/app/assets/stylesheets/participacion.scss +++ b/app/assets/stylesheets/participacion.scss @@ -801,6 +801,10 @@ img.initialjs-avatar { background: $association; } +.is-deleted { + background: $deleted; +} + .level-1 { background: $level-1; } diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 6240702d2..1954de5bd 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -76,6 +76,7 @@ $level-5: #F08A24; $author: #008CCF; $association: #C0392B; +$deleted: #E7E7E7; $comment-author: rgba(45,144,248,.15); $comment-level-5: rgba(255,241,204,1); diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 5ffff4a85..9052bc7cd 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,8 +1,10 @@
- <% if comment.not_visible? %> - <%= t("debates.comment.deleted") %> + <% if comment.not_visible? && comment.children_count > 0 %> +
+

<%= t("debates.comment.deleted") %>

+
<% else %> <% if comment.as_administrator? %> @@ -10,7 +12,6 @@ <% elsif comment.as_moderator? %> <%= image_tag("moderator_avatar.png", size: 32, class: "moderator-avatar left") %> <% else %> - <% if comment.user.organization? %> <%= image_tag("collective_avatar.png", size: 32, class: "avatar left") %> <% else %> @@ -19,7 +20,6 @@ <% if comment.user.hidden? %> <% end %> - <% end %>
@@ -91,11 +91,10 @@ <% end %>
- <% end %> -
- <%= render comment.children.for_render.reorder('id DESC, lft') %> -
+
+ <%= render comment.children.for_render.reorder('id DESC, lft') %> +
From b872d9a46d7ec67637d0ce3b4d8648e95df55053 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 28 Aug 2015 19:19:18 +0200 Subject: [PATCH 2/3] fixes failing specs --- .rspec | 1 + app/models/comment.rb | 4 ---- app/views/comments/_comment.html.erb | 11 ++++++----- spec/features/moderation/comments_spec.rb | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.rspec b/.rspec index f26ef5abe..3525ac0b2 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --color +--format Fuubar diff --git a/app/models/comment.rb b/app/models/comment.rb index fa5f72164..c23c5c993 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -61,10 +61,6 @@ class Comment < ActiveRecord::Base cached_votes_down end - def not_visible? - hidden? || user.hidden? - end - def ignored_flag? ignored_flag_at.present? end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 9052bc7cd..e21b148bc 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,12 +1,13 @@
- <% if comment.not_visible? && comment.children_count > 0 %> -
-

<%= t("debates.comment.deleted") %>

-
+ <% if comment.hidden? || comment.user.hidden? %> + <% if comment.children_count > 0 %> +
+

<%= t("debates.comment.deleted") %>

+
+ <% end %> <% else %> - <% if comment.as_administrator? %> <%= image_tag("admin_avatar.png", size: 32, class: "admin-avatar left") %> <% elsif comment.as_moderator? %> diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb index 6c2689f0e..4fdef5c10 100644 --- a/spec/features/moderation/comments_spec.rb +++ b/spec/features/moderation/comments_spec.rb @@ -4,7 +4,7 @@ feature 'Moderate Comments' do feature 'Hiding Comments' do - scenario 'Hide', :js do + scenario 'Hide without children hides the comment completely', :js do citizen = create(:user) moderator = create(:moderator) @@ -23,7 +23,7 @@ feature 'Moderate Comments' do visit debate_path(debate) expect(page).to have_css('.comment', count: 1) - expect(page).to have_content('This comment has been deleted') + expect(page).to_not have_content('This comment has been deleted') expect(page).to_not have_content('SPAM') end From 9ca71929cfde38a435cee4e0a0897d813eebcd50 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 28 Aug 2015 19:26:03 +0200 Subject: [PATCH 3/3] do not include foobar in rspec by default --- .rspec | 1 - 1 file changed, 1 deletion(-) diff --git a/.rspec b/.rspec index 3525ac0b2..f26ef5abe 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,2 @@ --color ---format Fuubar