mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Refactor user_badge_granted DiscourseEvent logic (#17579)
Follow-up to 02ce9b8a62
This commit is contained in:
committed by
GitHub
parent
9630095370
commit
78427e0797
@@ -482,14 +482,17 @@ describe BadgeGranter do
|
||||
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).to eq(nil)
|
||||
end
|
||||
|
||||
it 'calls user_badge_granted on backfilled badge' do
|
||||
it "triggers the 'user_badge_granted' DiscourseEvent per badge when badges are backfilled" do
|
||||
post = create_post(user: user)
|
||||
action = PostActionCreator.like(liker, post).post_action
|
||||
|
||||
Badge.any_instance.expects(:trigger_badge_granted_event).with(user.id).once
|
||||
Badge.any_instance.expects(:trigger_badge_granted_event).with(liker.id).once
|
||||
events = DiscourseEvent.track_events(:user_badge_granted) do
|
||||
BadgeGranter.process_queue!
|
||||
end
|
||||
|
||||
BadgeGranter.process_queue!
|
||||
expect(events.length).to eq(2)
|
||||
expect(events[0][:params]).to eq([Badge::FirstLike, liker.id])
|
||||
expect(events[1][:params]).to eq([Badge::Welcome, user.id])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user