mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: If posts are deleted they should be updated in consistency jobs
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe TopicFeaturedUsers do
|
||||
it 'ensures consistenct' do
|
||||
it 'ensures consistency' do
|
||||
|
||||
t = Fabricate(:topic)
|
||||
Fabricate(:post, topic_id: t.id, user_id: t.user_id)
|
||||
p2 = Fabricate(:post, topic_id: t.id)
|
||||
Fabricate(:post, topic_id: t.id, user_id: p2.user_id)
|
||||
p3 = Fabricate(:post, topic_id: t.id, user_id: p2.user_id)
|
||||
p4 = Fabricate(:post, topic_id: t.id)
|
||||
p5 = Fabricate(:post, topic_id: t.id)
|
||||
|
||||
@@ -14,11 +14,9 @@ describe TopicFeaturedUsers do
|
||||
featured_user2_id: 70,
|
||||
featured_user3_id: 12,
|
||||
featured_user4_id: 7,
|
||||
last_post_user_id: p5.user_id
|
||||
)
|
||||
last_post_user_id: p5.user_id)
|
||||
|
||||
TopicFeaturedUsers.ensure_consistency!
|
||||
|
||||
t.reload
|
||||
|
||||
expect(t.featured_user1_id).to eq(p2.user_id)
|
||||
@@ -26,6 +24,16 @@ describe TopicFeaturedUsers do
|
||||
expect(t.featured_user3_id).to eq(nil)
|
||||
expect(t.featured_user4_id).to eq(nil)
|
||||
|
||||
# after removing a post
|
||||
p2.update_column(:deleted_at, Time.now)
|
||||
p3.update_column(:hidden, true)
|
||||
|
||||
TopicFeaturedUsers.ensure_consistency!
|
||||
t.reload
|
||||
|
||||
expect(t.featured_user1_id).to eq(p4.user_id)
|
||||
expect(t.featured_user2_id).to eq(nil)
|
||||
expect(t.featured_user3_id).to eq(nil)
|
||||
expect(t.featured_user4_id).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user