DEV: Add test for web hooks and topic tags changes (#16493)

This commit is contained in:
Bianca Nenciu 2022-04-19 20:48:32 +03:00 committed by GitHub
parent 68497bddf2
commit 056c7a3f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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