mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:17:36 +08:00
FIX: Polymorphic bookmarks for new user narrative bot (#16683)
This commit allows the new user narrative bot to work with polymorphic bookmarks, gated behind the use_polymorphic_bookmarks site setting.
This commit is contained in:
@ -248,7 +248,22 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should create the right reply when bookmarks with reminders are enabled' do
|
||||
it 'adds an after commit model callback to bookmark' do
|
||||
Jobs.run_later!
|
||||
bookmark = Fabricate(:bookmark, post: Fabricate(:post))
|
||||
expect_job_enqueued(job: :bot_input, args: { user_id: bookmark.user_id, post_id: bookmark.post_id, input: "bookmark" })
|
||||
end
|
||||
|
||||
it 'adds an after commit model callback to bookmark for polymorphic bookmarks (but only for post polymorphic bookmarks)' do
|
||||
SiteSetting.use_polymorphic_bookmarks = true
|
||||
Jobs.run_later!
|
||||
bookmark = Fabricate(:bookmark, bookmarkable: Fabricate(:post))
|
||||
expect_job_enqueued(job: :bot_input, args: { user_id: bookmark.user_id, post_id: bookmark.bookmarkable_id, input: "bookmark" })
|
||||
bookmark2 = Fabricate(:bookmark, bookmarkable: Fabricate(:topic))
|
||||
expect_not_enqueued_with(job: :bot_input, args: { user_id: bookmark.user_id, post_id: kind_of(Integer), input: "bookmark" })
|
||||
end
|
||||
|
||||
it 'should create the right reply when the bookmark is created' do
|
||||
post.update!(user: discobot_user)
|
||||
narrative.expects(:enqueue_timeout_job).with(user)
|
||||
|
||||
|
Reference in New Issue
Block a user