A platform for community discussion. Free, open, simple.
FEATURE: add topic voting webhook event type (#23072)
Renato Atilio840bea3c517a
diff --git a/app/models/web_hook_event_type.rb b/app/models/web_hook_event_type.rbindex df3274802b4..818b4353bc8 100644--- a/app/models/web_hook_event_type.rb+++ b/app/models/web_hook_event_type.rb@@ -15,6 +15,7 @@ class WebHookEventType < ActiveRecord::BaseGROUP_USER = 14LIKE = 15USER_PROMOTED = 16+ TOPIC_VOTING = 17has_and_belongs_to_many :web_hooks@@ -30,6 +31,9 @@ class WebHookEventType < ActiveRecord::Baseunless defined?(SiteSetting.assign_enabled) && SiteSetting.assign_enabledids_to_exclude << ASSIGNend+ unless defined?(SiteSetting.voting_enabled) && SiteSetting.voting_enabled+ ids_to_exclude << TOPIC_VOTING+ endself.where.not(id: ids_to_exclude)enddiff --git a/db/fixtures/007_web_hook_event_types.rb b/db/fixtures/007_web_hook_event_types.rbindex 7990d1b16ea..3bf745381c7 100644--- a/db/fixtures/007_web_hook_event_types.rb+++ b/db/fixtures/007_web_hook_event_types.rb@@ -69,3 +69,8 @@ WebHookEventType.seed do |b|b.id = WebHookEventType::USER_PROMOTEDb.name = "user_promoted"end++WebHookEventType.seed do |b|+ b.id = WebHookEventType::TOPIC_VOTING+ b.name = "topic_voting"+enddiff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rbindex 5a6bf1757ab..196f91a0e0c 100644--- a/spec/models/web_hook_spec.rb+++ b/spec/models/web_hook_spec.rb@@ -54,8 +54,16 @@ RSpec.describe WebHook doit "includes enabled plugin web_hooks" doSiteSetting.stubs(:solved_enabled).returns(true)- web_hook_event_types = WebHookEventType.active.where(name: "solved")- expect(web_hook_event_types.count).to eq(1)+ solved_event_types = WebHookEventType.active.where(name: "solved")+ expect(solved_event_types.count).to eq(1)++ SiteSetting.stubs(:assign_enabled).returns(true)+ assign_event_types = WebHookEventType.active.where(name: "assign")+ expect(assign_event_types.count).to eq(1)++ SiteSetting.stubs(:voting_enabled).returns(true)+ voting_event_types = WebHookEventType.active.where(name: "topic_voting")+ expect(voting_event_types.count).to eq(1)enddescribe "#active_web_hooks" do