mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
Add new web hook serializers
This commit is contained in:
@ -21,6 +21,9 @@ Fabricator(:wildcard_web_hook, from: :web_hook) do
|
||||
wildcard_web_hook true
|
||||
end
|
||||
|
||||
Fabricator(:post_web_hook, from: :web_hook) do
|
||||
end
|
||||
|
||||
Fabricator(:topic_web_hook, from: :web_hook) do
|
||||
transient topic_hook: WebHookEventType.find_by(name: 'topic')
|
||||
|
||||
@ -36,3 +39,19 @@ Fabricator(:user_web_hook, from: :web_hook) do
|
||||
web_hook.web_hook_event_types = [transients[:user_hook]]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:group_web_hook, from: :web_hook) do
|
||||
transient group_hook: WebHookEventType.find_by(name: 'group')
|
||||
|
||||
after_build do |web_hook, transients|
|
||||
web_hook.web_hook_event_types = [transients[:group_hook]]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:category_web_hook, from: :web_hook) do
|
||||
transient category_hook: WebHookEventType.find_by(name: 'category')
|
||||
|
||||
after_build do |web_hook, transients|
|
||||
web_hook.web_hook_event_types = [transients[:category_hook]]
|
||||
end
|
||||
end
|
||||
|
@ -56,9 +56,14 @@ describe Jobs::EmitWebHookEvent do
|
||||
stub_request(:post, "https://meta.discourse.org/webhook_listener")
|
||||
.to_return(body: 'OK', status: 200)
|
||||
|
||||
expect do
|
||||
subject.execute(web_hook_id: post_hook.id, event_type: 'post', post_id: post.id)
|
||||
end.to change(WebHookEvent, :count).by(1)
|
||||
WebHookEventType.all.pluck(:name).each do |name|
|
||||
web_hook_id = Fabricate("#{name}_web_hook").id
|
||||
object_id = Fabricate(name).id
|
||||
|
||||
expect do
|
||||
subject.execute(web_hook_id: web_hook_id, event_type: name, "#{name}_id": object_id)
|
||||
end.to change(WebHookEvent, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'skips silently on missing post' do
|
||||
|
Reference in New Issue
Block a user