diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 93ce7768d46e1..983376edb52af 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -424,6 +424,7 @@ def destroy_many ).destroy end end + DiscourseEvent.trigger(:posts_destroyed, posts, current_user) render body: nil end diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb index 20e1166b952f3..d9b24b96e6ee0 100644 --- a/spec/requests/posts_controller_spec.rb +++ b/spec/requests/posts_controller_spec.rb @@ -405,6 +405,18 @@ delete "/posts/destroy_many.json", params: { post_ids: [post1.id, post2.id] } expect(response.status).to eq(200) end + # bookmark + it "triggers DiscourseEvent with :posts_destroyed and correct params" do + sign_in(poster) + events = + DiscourseEvent.track_events do + delete "/posts/destroy_many.json", params: { post_ids: [post1.id, post2.id] } + end + event = events.find { |e| e[:event_name] == :posts_destroyed } + expect(event).to be_present + expect(event[:params][0].length).to eq(2) + expect(event[:params][1]).to eq(poster) + end it "updates the highest read data for the forum" do sign_in(poster)