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:
Martin Brennan
2020-07-14 14:43:41 +10:00
committed by GitHub
parent f4f3e8c401
commit bcc80e0ea8
9 changed files with 78 additions and 8 deletions

View File

@@ -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])