mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 00:23:58 +08:00
27699648ef
Instead of going to the OP of the topic for topic-level bookmarks (which are bookmarks where for_topic is true) when clicking on the bookmark in the quick access menu or on the user bookmark list, this commit takes the user to the last unread post in the topic instead. This should be generally more useful than landing on the unchanging OP. To make this work nicely, I needed to add the last_read_post_number to the BookmarkQuery based on the TopicUser association. It should not add too much extra weight to the query, because it is limited to the user that we are fetching bookmarks for. Also fixed an issue where the bookmark serializer highest_post_number was not taking into account whether the user was staff, which is when we should use highest_staff_post_number instead.
29 lines
702 B
Ruby
29 lines
702 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe UserBookmarkList do
|
|
let(:params) { {} }
|
|
fab!(:user) { Fabricate(:user) }
|
|
let(:list) { UserBookmarkList.new(user: user, guardian: Guardian.new(user), params: params) }
|
|
|
|
before do
|
|
22.times do
|
|
bookmark = Fabricate(:bookmark, user: user)
|
|
Fabricate(:topic_user, topic: bookmark.topic, user: user)
|
|
end
|
|
end
|
|
|
|
it "defaults to 20 per page" do
|
|
expect(list.per_page).to eq(20)
|
|
end
|
|
|
|
context "when the per_page param is too high" do
|
|
let(:params) { { per_page: 1000 } }
|
|
|
|
it "does not allow more than X bookmarks to be requested per page" do
|
|
expect(list.load.count).to eq(20)
|
|
end
|
|
end
|
|
end
|