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
This commit is contained in:
Andy Zhao 2019-06-20 15:48:21 -04:00 committed by Ben Halpern
parent 8ec4e338ed
commit 4ca7197696
5 changed files with 12 additions and 2 deletions

View file

@ -348,6 +348,9 @@
}
}
}
.single-notification {
cursor: default;
}
.unseen {
@include themeable(
background,

View file

@ -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

View file

@ -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 %>

View file

@ -2,7 +2,7 @@
<% @notifications.each do |notification| %>
<% next if notification.notified_at < 24.hours.ago && notification.aggregated? %>
<% notification_count += 1 %>
<div class="single-article single-article-small-pic <%= "unseen" unless notification.read? %>" data-notification-id="<%= notification.id %>">
<div class="single-article single-article-small-pic single-notification <%= "unseen" unless notification.read? %>" data-notification-id="<%= notification.id %>">
<%= render notification.notifiable_type.downcase.to_s, notification: notification %>
</div>
<% rescue => e %>

View file

@ -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