mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
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
|
||||
|
||||
DB.exec(sql, args)
|
||||
|
||||
DiscourseEvent.trigger(:topic_hot_scores_updated)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -124,5 +124,20 @@ RSpec.describe TopicHotScore do
|
|||
TopicHotScore.where(topic_id: topic1.id).pluck(:recent_likes)
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user