DEV: Trigger an event after updating topic hot scores (#29261)
This commit is contained in:
parent
e95edd079b
commit
f227f66b11
|
@ -145,6 +145,8 @@ class TopicHotScore < ActiveRecord::Base
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
DB.exec(sql, args)
|
DB.exec(sql, args)
|
||||||
|
|
||||||
|
DiscourseEvent.trigger(:topic_hot_scores_updated)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -124,5 +124,20 @@ RSpec.describe TopicHotScore do
|
||||||
TopicHotScore.where(topic_id: topic1.id).pluck(:recent_likes)
|
TopicHotScore.where(topic_id: topic1.id).pluck(:recent_likes)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "triggers an event after updating" do
|
||||||
|
triggered = false
|
||||||
|
blk = Proc.new { triggered = true }
|
||||||
|
|
||||||
|
begin
|
||||||
|
DiscourseEvent.on(:topic_hot_scores_updated, &blk)
|
||||||
|
|
||||||
|
TopicHotScore.update_scores
|
||||||
|
|
||||||
|
expect(triggered).to eq(true)
|
||||||
|
ensure
|
||||||
|
DiscourseEvent.off(:topic_hot_scores_updated, &blk)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue