mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
FEATURE: add topic voting webhook event type (#23072)
* FEATURE: add topic upvote webhook event type * DEV: use a generic event type name for other actions in the same plugin
This commit is contained in:
parent
6de4b3ac3f
commit
840bea3c51
@ -15,6 +15,7 @@ class WebHookEventType < ActiveRecord::Base
|
|||||||
GROUP_USER = 14
|
GROUP_USER = 14
|
||||||
LIKE = 15
|
LIKE = 15
|
||||||
USER_PROMOTED = 16
|
USER_PROMOTED = 16
|
||||||
|
TOPIC_VOTING = 17
|
||||||
|
|
||||||
has_and_belongs_to_many :web_hooks
|
has_and_belongs_to_many :web_hooks
|
||||||
|
|
||||||
@ -30,6 +31,9 @@ class WebHookEventType < ActiveRecord::Base
|
|||||||
unless defined?(SiteSetting.assign_enabled) && SiteSetting.assign_enabled
|
unless defined?(SiteSetting.assign_enabled) && SiteSetting.assign_enabled
|
||||||
ids_to_exclude << ASSIGN
|
ids_to_exclude << ASSIGN
|
||||||
end
|
end
|
||||||
|
unless defined?(SiteSetting.voting_enabled) && SiteSetting.voting_enabled
|
||||||
|
ids_to_exclude << TOPIC_VOTING
|
||||||
|
end
|
||||||
|
|
||||||
self.where.not(id: ids_to_exclude)
|
self.where.not(id: ids_to_exclude)
|
||||||
end
|
end
|
||||||
|
@ -69,3 +69,8 @@ WebHookEventType.seed do |b|
|
|||||||
b.id = WebHookEventType::USER_PROMOTED
|
b.id = WebHookEventType::USER_PROMOTED
|
||||||
b.name = "user_promoted"
|
b.name = "user_promoted"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
WebHookEventType.seed do |b|
|
||||||
|
b.id = WebHookEventType::TOPIC_VOTING
|
||||||
|
b.name = "topic_voting"
|
||||||
|
end
|
||||||
|
@ -54,8 +54,16 @@ RSpec.describe WebHook do
|
|||||||
|
|
||||||
it "includes enabled plugin web_hooks" do
|
it "includes enabled plugin web_hooks" do
|
||||||
SiteSetting.stubs(:solved_enabled).returns(true)
|
SiteSetting.stubs(:solved_enabled).returns(true)
|
||||||
web_hook_event_types = WebHookEventType.active.where(name: "solved")
|
solved_event_types = WebHookEventType.active.where(name: "solved")
|
||||||
expect(web_hook_event_types.count).to eq(1)
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#active_web_hooks" do
|
describe "#active_web_hooks" do
|
||||||
|
Loading…
Reference in New Issue
Block a user