Skip to content

A platform for community discussion. Free, open, simple.

FIX: post edited webhook does not reflect updated topic title

Blake Ericksonc97244ca115c
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index 0deb6b2efdb..99ff5fb6258 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 = PostRevisor.new(first_post, topic).revise!(current_user, changes, validate_post: false)
+ success = PostRevisor.new(first_post).revise!(current_user, changes, validate_post: false)
end
# 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 0f0a921e9e8..947d244971b 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -946,6 +946,9 @@ RSpec.describe TopicsController do
end
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}/#{topic.id}.json"
@@ -971,6 +974,13 @@ RSpec.describe TopicsController do
topic.reload
expect(topic.title).to eq('This is a new title for the topic')
+
+ expect(Jobs::EmitWebHookEvent.jobs.length).to eq(2)
+ job_args = Jobs::EmitWebHookEvent.jobs[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')
end
it "returns errors with invalid titles" do