2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-10 08:38:11 +08:00

FIX: Don't display webhooks for inactive plugins (#9206)

* FIX: Don't display webhooks for inactive plugins

This commit ensures that we don't show webhooks for plugins that are not
installed or that are disabled.

Bug report:

https://meta.discourse.org/t/webhookeventtype-and-the-solved-and-assign-plugins/144180

* rename to just 'active', it's cleaner
This commit is contained in:
Blake Erickson 2020-03-17 10:39:24 -06:00 committed by GitHub
parent e950471c0f
commit 919e405c48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -44,6 +44,22 @@ describe WebHook do
expect(post_hook.payload_url).to eq("https://example.com")
end
it "excludes disabled plugin web_hooks" do
web_hook_event_types = WebHookEventType.active.find_by(name: 'solved')
expect(web_hook_event_types).to eq(nil)
end
it "includes non-plugin web_hooks" do
web_hook_event_types = WebHookEventType.active.where(name: 'topic')
expect(web_hook_event_types.count).to eq(1)
end
it "includes enabled plugin web_hooks" do
SiteSetting.stubs(:solved_enabled).returns(true)
web_hook_event_types = WebHookEventType.active.where(name: 'solved')
expect(web_hook_event_types.count).to eq(1)
end
describe '#active_web_hooks' do
it "returns unique hooks" do
post_hook.web_hook_event_types << WebHookEventType.find_by(name: 'topic')