From 4ca719769686258636f62fb2d843c8f2ea9d7d97 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Thu, 20 Jun 2019 15:48:21 -0400 Subject: [PATCH] Delete a comment's title if it is deleted (#3249) * Remove cursor pointer for notification cards * Delete the comment title if deleted * Update title to use comment's title --- app/assets/stylesheets/notifications.scss | 3 +++ app/models/comment.rb | 2 ++ app/views/comments/index.html.erb | 2 +- app/views/notifications/_notifications_list.html.erb | 2 +- spec/models/comment_spec.rb | 5 +++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss index 44239f38f..557afc871 100644 --- a/app/assets/stylesheets/notifications.scss +++ b/app/assets/stylesheets/notifications.scss @@ -348,6 +348,9 @@ } } } + .single-notification { + cursor: default; + } .unseen { @include themeable( background, diff --git a/app/models/comment.rb b/app/models/comment.rb index 555f4f25c..e699d6c29 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -164,6 +164,8 @@ class Comment < ApplicationRecord end def title + return "[deleted]" if deleted + ActionController::Base.helpers.truncate(ActionController::Base.helpers.strip_tags(processed_html), length: 80) end diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb index 14ed792af..9f4f646cd 100644 --- a/app/views/comments/index.html.erb +++ b/app/views/comments/index.html.erb @@ -1,5 +1,5 @@ <% if @root_comment.present? %> - <% title truncate(strip_tags(@root_comment.processed_html), length: 100) + " — DEV" %> + <% title @root_comment.title + " — DEV" %> <% else %> <% title "Discussion of " + @commentable.title + " — DEV" %> <% end %> diff --git a/app/views/notifications/_notifications_list.html.erb b/app/views/notifications/_notifications_list.html.erb index fc18de2c4..641f0df28 100644 --- a/app/views/notifications/_notifications_list.html.erb +++ b/app/views/notifications/_notifications_list.html.erb @@ -2,7 +2,7 @@ <% @notifications.each do |notification| %> <% next if notification.notified_at < 24.hours.ago && notification.aggregated? %> <% notification_count += 1 %> -
" data-notification-id="<%= notification.id %>"> +
" data-notification-id="<%= notification.id %>"> <%= render notification.notifiable_type.downcase.to_s, notification: notification %>
<% rescue => e %> diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 7ac767274..bc125bd9a 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -174,6 +174,11 @@ RSpec.describe Comment, type: :model do text = comment.title.gsub("...", "").delete("\n") expect(comment.processed_html).to include CGI.unescapeHTML(text) end + + it "is converted to deleted if the comment is deleted" do + comment.update_column(:deleted, true) + expect(comment.title).to eq "[deleted]" + end end describe "#custom_css" do