mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:39:36 -06:00
fcc2e7ebbf
This commit migrates all bookmarks to be polymorphic (using the bookmarkable_id and bookmarkable_type) columns. It also deletes all the old code guarded behind the use_polymorphic_bookmarks setting and changes that setting to true for all sites and by default for the sake of plugins. No data is deleted in the migrations, the old post_id and for_topic columns for bookmarks will be dropped later on.
24 lines
762 B
Ruby
24 lines
762 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UserPostBookmarkSerializer do
|
|
let(:user) { Fabricate(:user) }
|
|
let(:post) { Fabricate(:post, user: user, topic: topic) }
|
|
let(:topic) { Fabricate(:topic) }
|
|
let!(:bookmark) { Fabricate(:bookmark, name: 'Test', user: user, bookmarkable: post) }
|
|
|
|
it "uses the correct highest_post_number column based on whether the user is staff" do
|
|
Fabricate(:post, topic: topic)
|
|
Fabricate(:post, topic: topic)
|
|
Fabricate(:whisper, topic: topic)
|
|
topic.reload
|
|
bookmark.reload
|
|
serializer = UserPostBookmarkSerializer.new(bookmark, scope: Guardian.new(user))
|
|
|
|
expect(serializer.highest_post_number).to eq(3)
|
|
|
|
user.update!(admin: true)
|
|
|
|
expect(serializer.highest_post_number).to eq(4)
|
|
end
|
|
end
|