From 056c7a3f30712061e14757d7c222a31fea338951 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Tue, 19 Apr 2022 20:48:32 +0300 Subject: [PATCH] DEV: Add test for web hooks and topic tags changes (#16493) --- spec/models/web_hook_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index 03c9c1ba2a7..2f391272d11 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -135,6 +135,7 @@ describe WebHook do let(:topic) { Fabricate(:topic, user: user) } let(:post) { Fabricate(:post, topic: topic, user: user) } let(:topic_web_hook) { Fabricate(:topic_web_hook) } + let(:tag) { Fabricate(:tag) } before do topic_web_hook @@ -206,6 +207,21 @@ describe WebHook do payload = JSON.parse(job_args["payload"]) expect(payload["id"]).to eq(topic_id) expect(payload["category_id"]).to eq(category.id) + + expect do + successfully_saved_post_and_topic = PostRevisor.new(post, post.topic).revise!( + post.user, + { tags: [tag.name] }, + { skip_validations: true }, + ) + end.to change { Jobs::EmitWebHookEvent.jobs.length }.by(1) + + job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first + + expect(job_args["event_name"]).to eq("topic_edited") + payload = JSON.parse(job_args["payload"]) + expect(payload["id"]).to eq(topic_id) + expect(payload["tags"]).to contain_exactly(tag.name) end describe 'when topic has been deleted' do