FIX: post edited webhook does not reflect updated topic title

FIX: post edited webhook does not reflect updated topic title

This fix ensures that when a topic title is edited the new title shows up in the post webhook instead of the old title.

Rather than passing in the old topic object to the PostRevisor the PostRevisor initializer will load the updated topic object inside of the initializer if you don’t pass it in. This will allow the post_edited webhook to have the correct topic values.

Original bug reported at:

diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index 0deb6b2..99ff5fb 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -366,7 +366,7 @@ class TopicsController < ApplicationController
     if changes.length > 0
       first_post = topic.ordered_posts.first
-      success =, topic).revise!(current_user, changes, validate_post: false)
+      success =!(current_user, changes, validate_post: false)
     # this is used to return the title to the client as it may have been changed by "TextCleaner"
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 0f0a921..947d244 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -946,6 +946,9 @@ RSpec.describe TopicsController do
       describe 'with permission' do
+        fab!(:post_hook) { Fabricate(:post_web_hook) }
+        fab!(:topic_hook) { Fabricate(:topic_web_hook) }
         it 'succeeds' do
           put "/t/#{topic.slug}/#{}.json"
@@ -971,6 +974,13 @@ RSpec.describe TopicsController do
           expect(topic.title).to eq('This is a new title for the topic')
+          expect( eq(2)
+          job_args =[0]["args"].first
+          expect(job_args["event_name"]).to eq("post_edited")
+          payload = JSON.parse(job_args["payload"])
+          expect(payload["topic_title"]).to eq('This is a new title for the topic')
         it "returns errors with invalid titles" do

GitHub sha: c97244ca

This commit has been mentioned on Discourse Meta. There might be relevant details there: