mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 14:11:16 +08:00
FIX: Add bookmark limits (#11725)
Adds a bookmark search per page limit, a total bookmark creation limit, and a rate limit per day for bookmark creation.
This commit is contained in:
27
spec/models/user_bookmark_list_spec.rb
Normal file
27
spec/models/user_bookmark_list_spec.rb
Normal file
@ -0,0 +1,27 @@
|
||||
# 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
|
||||
Fabricate(:bookmark, 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
|
Reference in New Issue
Block a user