Skip to content

A platform for community discussion. Free, open, simple.

DEV: Update webhook site setting for topic voting (#27935)

Natalie Tay7d02b453048c
diff --git a/app/models/web_hook_event_type.rb b/app/models/web_hook_event_type.rb
index 9e8303c427a..f4120e7cab9 100644
--- a/app/models/web_hook_event_type.rb
+++ b/app/models/web_hook_event_type.rb
@@ -103,7 +103,7 @@ class WebHookEventType < ActiveRecord::Base
unless defined?(SiteSetting.assign_enabled) && SiteSetting.assign_enabled
ids_to_exclude.concat([TYPES[:assign_assigned], TYPES[:assign_unassigned]])
end
- unless defined?(SiteSetting.voting_enabled) && SiteSetting.voting_enabled
+ unless defined?(SiteSetting.topic_voting_enabled) && SiteSetting.topic_voting_enabled
ids_to_exclude.concat([TYPES[:voting_topic_upvote], TYPES[:voting_topic_unvote]])
end
unless defined?(SiteSetting.chat_enabled) && SiteSetting.chat_enabled
diff --git a/spec/models/web_hook_event_type_spec.rb b/spec/models/web_hook_event_type_spec.rb
index 003d48bbbe7..471f67bd449 100644
--- a/spec/models/web_hook_event_type_spec.rb
+++ b/spec/models/web_hook_event_type_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe WebHookEventType do
describe "#active" do
it "returns only active types" do
core_event_types = WebHookEventType.active.map(&:name)
- expect(core_event_types).to eq(
+ expect(core_event_types).to match_array(
%w[
topic_created
topic_revised
@@ -47,10 +47,10 @@ RSpec.describe WebHookEventType do
SiteSetting.stubs(:solved_enabled).returns(true)
SiteSetting.stubs(:assign_enabled).returns(true)
- SiteSetting.stubs(:voting_enabled).returns(true)
+ SiteSetting.stubs(:topic_voting_enabled).returns(true)
SiteSetting.stubs(:chat_enabled).returns(true)
plugins_event_types = WebHookEventType.active.map(&:name) - core_event_types
- expect(plugins_event_types).to eq(
+ expect(plugins_event_types).to match_array(
%w[
accepted_solution
unaccepted_solution
diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb
index 67a9ef09262..5e631c8edcc 100644
--- a/spec/models/web_hook_spec.rb
+++ b/spec/models/web_hook_spec.rb
@@ -57,7 +57,7 @@ RSpec.describe WebHook do
assign_event_types = WebHookEventType.active.where(group: "assign").pluck(:name)
expect(assign_event_types).to eq(%w[assigned unassigned])
- SiteSetting.stubs(:voting_enabled).returns(true)
+ SiteSetting.stubs(:topic_voting_enabled).returns(true)
voting_event_types = WebHookEventType.active.where(group: "voting").pluck(:name)
expect(voting_event_types).to eq(%w[topic_upvote topic_unvote])
#