2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe PostAction do
|
2018-08-17 00:11:29 +08:00
|
|
|
it "triggers the 'flag_reviewed' event when there was at least one flag" do
|
2024-01-29 17:52:02 +08:00
|
|
|
user = Fabricate(:user, trust_level: TrustLevel[4])
|
2018-08-17 00:11:29 +08:00
|
|
|
|
|
|
|
post = Fabricate(:post)
|
2024-01-29 17:52:02 +08:00
|
|
|
events = DiscourseEvent.track_events { PostDestroyer.new(user, post).destroy }
|
2018-08-17 00:11:29 +08:00
|
|
|
expect(events.map { |e| e[:event_name] }).to_not include(:flag_reviewed)
|
|
|
|
|
|
|
|
flagged_post = Fabricate(:post)
|
2024-01-29 17:52:02 +08:00
|
|
|
PostActionCreator.spam(user, flagged_post)
|
|
|
|
events = DiscourseEvent.track_events { PostDestroyer.new(user, flagged_post).destroy }
|
2018-08-17 00:11:29 +08:00
|
|
|
expect(events.map { |e| e[:event_name] }).to include(:flag_reviewed)
|
|
|
|
end
|
|
|
|
end
|