mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 16:48:55 +08:00
DEV: Minor review fixes and fix bookmark spec logging (#9045)
As per: https://review.discourse.org/t/fix-never-allow-custom-emoji-to-be-marked-secure-8965/9072 https://review.discourse.org/t/feature-improving-bookmarks-part-2-topic-bookmarking-8954/9038
This commit is contained in:
parent
4635be10c8
commit
8123538c94
@ -918,8 +918,8 @@ class Post < ActiveRecord::Base
|
|||||||
if SiteSetting.secure_media?
|
if SiteSetting.secure_media?
|
||||||
Upload.where(
|
Upload.where(
|
||||||
id: upload_ids, access_control_post_id: nil
|
id: upload_ids, access_control_post_id: nil
|
||||||
).where.not(
|
).where(
|
||||||
id: CustomEmoji.pluck(:upload_id)
|
'id NOT IN (SELECT upload_id FROM custom_emojis)'
|
||||||
).update_all(
|
).update_all(
|
||||||
access_control_post_id: self.id
|
access_control_post_id: self.id
|
||||||
)
|
)
|
||||||
|
@ -17,8 +17,14 @@ RSpec.describe "bookmarks tasks" do
|
|||||||
create_post_actions_and_existing_bookmarks
|
create_post_actions_and_existing_bookmarks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def invoke_task(args = nil)
|
||||||
|
capture_stdout do
|
||||||
|
Rake::Task['bookmarks:sync_to_table'].invoke(args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "migrates all PostActions" do
|
it "migrates all PostActions" do
|
||||||
Rake::Task['bookmarks:sync_to_table'].invoke
|
invoke_task
|
||||||
|
|
||||||
expect(Bookmark.all.count).to eq(3)
|
expect(Bookmark.all.count).to eq(3)
|
||||||
end
|
end
|
||||||
@ -26,14 +32,14 @@ RSpec.describe "bookmarks tasks" do
|
|||||||
it "does not create bookmarks that already exist in the bookmarks table for a user" do
|
it "does not create bookmarks that already exist in the bookmarks table for a user" do
|
||||||
Fabricate(:bookmark, user: user1, post: post1)
|
Fabricate(:bookmark, user: user1, post: post1)
|
||||||
|
|
||||||
Rake::Task['bookmarks:sync_to_table'].invoke
|
invoke_task
|
||||||
|
|
||||||
expect(Bookmark.all.count).to eq(3)
|
expect(Bookmark.all.count).to eq(3)
|
||||||
expect(Bookmark.where(post: post1, user: user1).count).to eq(1)
|
expect(Bookmark.where(post: post1, user: user1).count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "respects the sync_limit if provided and stops creating bookmarks at the limit (so this can be run progrssively" do
|
it "respects the sync_limit if provided and stops creating bookmarks at the limit (so this can be run progrssively" do
|
||||||
Rake::Task['bookmarks:sync_to_table'].invoke(1)
|
invoke_task(1)
|
||||||
expect(Bookmark.all.count).to eq(1)
|
expect(Bookmark.all.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user