FEATURE: Event on topic merge (#6057)
This commit is contained in:
parent
6cc860be09
commit
10bc69a62f
|
@ -913,6 +913,7 @@ class Topic < ActiveRecord::Base
|
|||
|
||||
if opts[:destination_topic_id]
|
||||
post_mover.to_topic opts[:destination_topic_id]
|
||||
DiscourseEvent.trigger(:topic_merged, post_mover.original_topic, post_mover.destination_topic)
|
||||
elsif opts[:title]
|
||||
post_mover.to_new_topic(opts[:title], opts[:category_id], opts[:tags])
|
||||
end
|
||||
|
|
|
@ -201,6 +201,13 @@ RSpec.describe TopicsController do
|
|||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
||||
it "triggers an event on merge" do
|
||||
DiscourseEvent.on(:topic_merged) do |original_topic, destination_topic|
|
||||
expect(original_topic.id).to eq(topic.id)
|
||||
expect(destination_topic.id).to eq(dest_topic.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'failure' do
|
||||
|
|
Loading…
Reference in New Issue