mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 09:43:44 +08:00
f5f3742166
* FIX: respect creation date when paginating group activity posts There are scenarios where the chronological order of posts doesn't match the order of their IDs. For instance, when moving the first post from one topic or PM to another, a new post (with a higher ID) will be created, but it will retain the original creation time. This PR changes the group activity page and endpoint to paginate posts using created_at instead of relying on ID ordering.
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Group activity", type: :system do
|
|
fab!(:user) { Fabricate(:user) }
|
|
fab!(:group) { Fabricate(:group) }
|
|
|
|
context "when on the posts activity page" do
|
|
let(:posts_page) { PageObjects::Pages::GroupActivityPosts.new }
|
|
|
|
before do
|
|
group.add(user)
|
|
sign_in(user)
|
|
|
|
40.times { Fabricate(:post, user: user, topic: Fabricate(:topic, user: user)) }
|
|
|
|
# higher id, older post
|
|
older_post =
|
|
Fabricate(:post, user: user, topic: Fabricate(:topic, user: user), raw: "older post")
|
|
older_post.update!(created_at: 1.day.ago)
|
|
end
|
|
|
|
it "loads and paginates the results by chronology" do
|
|
posts_page.visit(group)
|
|
|
|
expect(posts_page).to have_user_stream_item(count: 20)
|
|
expect(posts_page).not_to have_content("older post")
|
|
|
|
posts_page.scroll_to_last_item
|
|
|
|
expect(posts_page).to have_user_stream_item(count: 40)
|
|
expect(posts_page).not_to have_content("older post")
|
|
|
|
posts_page.scroll_to_last_item
|
|
|
|
expect(posts_page).to have_content("older post")
|
|
expect(posts_page).to have_user_stream_item(count: 41)
|
|
end
|
|
end
|
|
end
|