mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 17:55:59 +08:00
DEV: Add posts_moved DiscourseEvent in PostMover (#30066)
This commit is contained in:
parent
c67d3131aa
commit
a5636afb08
|
@ -113,6 +113,11 @@ class PostMover
|
||||||
close_topic_and_schedule_deletion if moving_all_posts
|
close_topic_and_schedule_deletion if moving_all_posts
|
||||||
|
|
||||||
destination_topic.reload
|
destination_topic.reload
|
||||||
|
DiscourseEvent.trigger(
|
||||||
|
:posts_moved,
|
||||||
|
destination_topic_id: destination_topic.id,
|
||||||
|
original_topic_id: original_topic.id,
|
||||||
|
)
|
||||||
destination_topic
|
destination_topic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -811,6 +811,21 @@ RSpec.describe PostMover do
|
||||||
expect(topic).to be_closed
|
expect(topic).to be_closed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "triggers posts_moved DiscourseEvent with correct args" do
|
||||||
|
events =
|
||||||
|
DiscourseEvent.track_events(:posts_moved) do
|
||||||
|
posts_to_move = [p1.id, p2.id, p3.id, p4.id]
|
||||||
|
topic.move_posts(user, posts_to_move, destination_topic_id: destination_topic.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(
|
||||||
|
events.detect do |e|
|
||||||
|
e[:params] ==
|
||||||
|
[{ destination_topic_id: destination_topic.id, original_topic_id: topic.id }]
|
||||||
|
end,
|
||||||
|
).to be_present
|
||||||
|
end
|
||||||
|
|
||||||
it "does not try to move small action posts" do
|
it "does not try to move small action posts" do
|
||||||
small_action =
|
small_action =
|
||||||
Fabricate(
|
Fabricate(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user