mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add search to user bookmark list (#10230)
User bookmarks can now be searched by name or post raw content. The q querystring param is hooked up from the Ember router as well.
This commit is contained in:
@@ -11,8 +11,9 @@ RSpec.describe BookmarkQuery do
|
||||
end
|
||||
|
||||
describe "#list_all" do
|
||||
fab!(:bookmark1) { Fabricate(:bookmark, user: user) }
|
||||
fab!(:bookmark2) { Fabricate(:bookmark, user: user) }
|
||||
fab!(:post) { Fabricate(:post, raw: "Some post content here") }
|
||||
fab!(:bookmark1) { Fabricate(:bookmark, user: user, name: "Check up later") }
|
||||
fab!(:bookmark2) { Fabricate(:bookmark, user: user, post: post, topic: post.topic) }
|
||||
|
||||
it "returns all the bookmarks for a user" do
|
||||
expect(bookmark_query.list_all.count).to eq(2)
|
||||
@@ -37,6 +38,18 @@ RSpec.describe BookmarkQuery do
|
||||
expect(preloaded_bookmarks.any?).to eq(true)
|
||||
end
|
||||
|
||||
context "when q param is provided" do
|
||||
it "can search by post content" do
|
||||
bookmarks = bookmark_query(params: { q: 'content' }).list_all
|
||||
expect(bookmarks.map(&:id)).to eq([bookmark2.id])
|
||||
end
|
||||
|
||||
it "can search by bookmark name" do
|
||||
bookmarks = bookmark_query(params: { q: 'check' }).list_all
|
||||
expect(bookmarks.map(&:id)).to eq([bookmark1.id])
|
||||
end
|
||||
end
|
||||
|
||||
context "for a whispered post" do
|
||||
before do
|
||||
bookmark1.post.update(post_type: Post.types[:whisper])
|
||||
|
||||
Reference in New Issue
Block a user