Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion decidim-core/app/cells/decidim/user_activity_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ def show
end

def activities
context[:activities]
resource_ids_to_filter = context[:activities].select { |log| log[:action] == "delete" && log[:resource_type] == "Decidim::Comments::Comment" }.map(&:resource_id)
if resource_ids_to_filter.any?
context[:activities].where.not("resource_id in (?) AND resource_type = ?", resource_ids_to_filter, "Decidim::Comments::Comment")
else
context[:activities]
end
end

def resource_types
Expand Down
27 changes: 27 additions & 0 deletions decidim-core/spec/cells/decidim/user_activity_cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,33 @@
end
end

context "when comment is deleted" do
let!(:logs) do
comments.first(14).map do |comment|
create(
:action_log,
action: "publish",
visibility: "all",
user: model,
resource: comment,
organization: component.organization,
participatory_space: component.participatory_space
)
end
end
let!(:log_one) { create(:action_log, action: "create", visibility: "all", user: model, resource: comments.last, organization: component.organization, participatory_space: component.participatory_space) }
let!(:log_two) { create(:action_log, action: "delete", visibility: "all", user: model, resource: comments.last, organization: component.organization, participatory_space: component.participatory_space) }

it "does not display the references to the comment on the first page if comment has been deleted" do
logs.last(2) do |log|
root_link = Decidim::ResourceLocatorPresenter.new(log.resource.root_commentable).path
comment_link = "#{root_link}?commentId=#{log.resource.id}#comment_#{log.resource.id}"
title = html_truncate(translated_attribute(log.resource.root_commentable.title), length: 80)
expect(subject).to have_no_link(title, href: comment_link)
end
end
end

context "when on the second page" do
let(:current_page) { 2 }

Expand Down
Loading