Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Fix last activity page showing recently updated records' to v0.27 #9989

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ def activities

def search_collection
ActionLog
.where(visibility: %w(public-only all))
.where(organization: current_organization)
.where(
organization: current_organization,
visibility: %w(public-only all)
)
.with_new_resource_type("all")
.order(created_at: :desc)
end

Expand Down
26 changes: 25 additions & 1 deletion decidim-core/spec/system/last_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

describe "Last activity", type: :system do
let(:organization) { create(:organization) }
let(:comment) { create(:comment) }
let(:commentable) { create(:dummy_resource, component: component) }
let(:comment) { create(:comment, commentable: commentable) }
let!(:action_log) do
create(:action_log, created_at: 1.day.ago, action: "create", visibility: "public-only", resource: comment, organization: organization)
end
Expand Down Expand Up @@ -95,6 +96,29 @@
expect(page).to have_css(".card--activity", count: 2)
end

context "when there are recently update old activities" do
let(:commentables) { create_list(:dummy_resource, 20, component: component) }
let(:comments) { commentables.map { |commentable| create(:comment, commentable: commentable) } }
let!(:action_logs) do
comments.map do |comment|
create(:action_log, created_at: 1.day.ago, action: "create", visibility: "public-only", resource: comment, organization: organization)
end
end

let(:old_commentable) { create(:dummy_resource, component: component) }
let(:old_comment) { create(:comment, commentable: old_commentable, created_at: 2.years.ago) }
let!(:create_action_log) { create(:action_log, created_at: 2.years.ago, action: "create", visibility: "public-only", resource: old_comment, organization: organization) }
let!(:update_action_log) { create(:action_log, created_at: 1.minute.ago, action: "update", visibility: "public-only", resource: old_comment, organization: organization) }

before do
visit current_path
end

it "doesn't show the old activities at the top of the list" do
expect(page).not_to have_content(translated(old_comment.commentable.title))
end
end

context "when there are activities from private spaces" do
before do
component.participatory_space.update(private_space: true)
Expand Down