FIX: Should not generate payload until active webhooks are exist

This commit is contained in:
Vinoth Kannan
2019-02-19 12:23:42 +05:30
parent 8cd4ceba49
commit f2c3415548
3 changed files with 13 additions and 4 deletions

View File

@@ -125,10 +125,13 @@ describe WebHook do
end
describe 'when there are no active hooks' do
it 'should not enqueue anything' do
it 'should not generate payload and enqueue anything' do
topic_web_hook.destroy!
post = PostCreator.create(user, raw: 'post', title: 'topic', skip_validations: true)
expect(Jobs::EmitWebHookEvent.jobs.length).to eq(0)
WebHook.expects(:generate_payload).times(0)
PostDestroyer.new(admin, post).destroy
end
end
@@ -384,6 +387,12 @@ describe WebHook do
expect(payload["id"]).to eq(tag.id)
end
it 'should not generate payload if webhooks not exist' do
WebHook.expects(:generate_payload).times(0)
tag = Fabricate(:tag)
tag.destroy!
end
it 'should enqueue the right hooks for flag events' do
post = Fabricate(:post)
admin = Fabricate(:admin)