mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:50:00 +08:00
DEV: Reserve webhook event types to be used in plugins (#9110)
* DEV: Reserve webhook event types to be used in plugins Based on feedback on the following PR's: https://github.com/discourse/discourse-solved/pull/85 https://github.com/discourse/discourse-assign/pull/61 This commit reserves ID's to be used for webhook event types to ensure that some other webhook or plugin doesn't end up using the same ID. * Fix broken test I don't think this test has to test ALL event types to verify that this feature is working. Now that we added some event types that plugins are using this test was failing for missing fabricators that exist in the respective plugins. * remove loop and just test first record
This commit is contained in:
parent
ef6b7bd776
commit
43b54c631d
|
@ -11,6 +11,8 @@ class WebHookEventType < ActiveRecord::Base
|
|||
QUEUED_POST = 8
|
||||
REVIEWABLE = 9
|
||||
NOTIFICATION = 10
|
||||
SOLVED = 11
|
||||
ASSIGN = 12
|
||||
|
||||
has_and_belongs_to_many :web_hooks
|
||||
|
||||
|
|
|
@ -49,3 +49,13 @@ WebHookEventType.seed do |b|
|
|||
b.id = WebHookEventType::NOTIFICATION
|
||||
b.name = "notification"
|
||||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::SOLVED
|
||||
b.name = "solved"
|
||||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::ASSIGN
|
||||
b.name = "assign"
|
||||
end
|
||||
|
|
|
@ -239,17 +239,16 @@ describe Jobs::EmitWebHookEvent do
|
|||
stub_request(:post, post_hook.payload_url)
|
||||
.to_return(body: 'OK', status: 200)
|
||||
|
||||
WebHookEventType.all.pluck(:name).each do |name|
|
||||
web_hook_id = Fabricate("#{name}_web_hook").id
|
||||
topic_event_type = WebHookEventType.all.first
|
||||
web_hook_id = Fabricate("#{topic_event_type.name}_web_hook").id
|
||||
|
||||
expect do
|
||||
subject.execute(
|
||||
web_hook_id: web_hook_id,
|
||||
event_type: name,
|
||||
payload: { test: "some payload" }.to_json
|
||||
)
|
||||
end.to change(WebHookEvent, :count).by(1)
|
||||
end
|
||||
expect do
|
||||
subject.execute(
|
||||
web_hook_id: web_hook_id,
|
||||
event_type: topic_event_type.name,
|
||||
payload: { test: "some payload" }.to_json
|
||||
)
|
||||
end.to change(WebHookEvent, :count).by(1)
|
||||
end
|
||||
|
||||
it 'sets up proper request headers' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user