A platform for community discussion. Free, open, simple.
DEV: retire topic voting badges upcoming change (#42924)
David Battersbyff0ae472b1b7
diff --git a/db/structure.sql b/db/structure.sqlindex 1f5ecc2e7ab..03b5bbd188e 100644--- a/db/structure.sql+++ b/db/structure.sql@@ -24419,6 +24419,7 @@ INSERT INTO "schema_migrations" (version) VALUES('20260827064809'),('20260826133816'),('20260826124054'),+('20260826121453'),('20260826090055'),('20260824214608'),('20260824214603'),diff --git a/plugins/discourse-topic-voting/app/services/discourse_topic_voting/enable_topic_voting_badges_toggled.rb b/plugins/discourse-topic-voting/app/services/discourse_topic_voting/enable_topic_voting_badges_toggled.rbdeleted file mode 100644index f2ac768fd53..00000000000--- a/plugins/discourse-topic-voting/app/services/discourse_topic_voting/enable_topic_voting_badges_toggled.rb+++ /dev/null@@ -1,22 +0,0 @@-# frozen_string_literal: true--# Reacts to the `enable_topic_voting_badges` upcoming change being enabled or-# disabled (manually or via auto-promotion). See the on(:upcoming_change_enabled)-# / on(:upcoming_change_disabled) subscriptions in plugin.rb for the dispatch.-#-# Enabling turns on the four seeded Topic Voting badges; disabling turns them-# back off.-#-# New sites are handled separately by the badge seed fixture-# (db/fixtures/001_badges.rb): the promotion event does not fire on brand-new-# sites (UpcomingChanges.should_notify_admins? is false there), so the seed is-# what gives freshly provisioned sites their enabled-by-default badges.-module DiscourseTopicVoting- class EnableTopicVotingBadgesToggled < Service::ActionBase- option :enabled-- def call- Badge.where(name: DiscourseTopicVoting::BADGE_NAMES).update_all(enabled:)- end- end-enddiff --git a/plugins/discourse-topic-voting/config/locales/server.en.yml b/plugins/discourse-topic-voting/config/locales/server.en.ymlindex e202acd52d8..5fd90dc96f4 100755--- a/plugins/discourse-topic-voting/config/locales/server.en.yml+++ b/plugins/discourse-topic-voting/config/locales/server.en.yml@@ -7,7 +7,6 @@ en:site_settings:enable_ideas_category_type_setup: "Enables the Ideas category type option during category creation setup."- enable_topic_voting_badges: "Enables the Topic Voting badges awarded to members when others vote for their ideas."topic_voting_enabled: 'Allow users to vote on topics?'topic_voting_enable_vote_limits: 'Limit the number of votes per user based on trust level'topic_voting_tl0_vote_limit: 'How many active votes are TL0 users allowed?'diff --git a/plugins/discourse-topic-voting/config/settings.yml b/plugins/discourse-topic-voting/config/settings.ymlindex 12c333a1517..c3c2301ddd3 100755--- a/plugins/discourse-topic-voting/config/settings.yml+++ b/plugins/discourse-topic-voting/config/settings.yml@@ -56,12 +56,3 @@ discourse_topic_voting:impact: "feature,staff"learn_more_url: "https://meta.discourse.org/t/-/399365"requires_plugin_enabled: false- enable_topic_voting_badges:- default: false- hidden: true- client: true- upcoming_change:- status: "stable"- impact: "site_setting_default,all_members"- learn_more_url: "https://meta.discourse.org/t/-/401731"- permanent_warning: falsediff --git a/plugins/discourse-topic-voting/db/post_migrate/20260826121453_remove_enable_topic_voting_badges_setting.rb b/plugins/discourse-topic-voting/db/post_migrate/20260826121453_remove_enable_topic_voting_badges_setting.rbnew file mode 100644index 00000000000..3c37099bece--- /dev/null+++ b/plugins/discourse-topic-voting/db/post_migrate/20260826121453_remove_enable_topic_voting_badges_setting.rb@@ -0,0 +1,12 @@+# frozen_string_literal: true++class RemoveEnableTopicVotingBadgesSetting < ActiveRecord::Migration[8.0]+ def up+ execute "DELETE FROM site_settings WHERE name = 'enable_topic_voting_badges'"+ execute "DELETE FROM site_setting_groups WHERE name = 'enable_topic_voting_badges'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/plugins/discourse-topic-voting/plugin.rb b/plugins/discourse-topic-voting/plugin.rbindex c075003c296..0f22b414eca 100755--- a/plugins/discourse-topic-voting/plugin.rb+++ b/plugins/discourse-topic-voting/plugin.rb@@ -230,18 +230,6 @@ after_initialize doDiscourseTopicVoting::UserMerger.merge(source_user, target_user)end- on(:upcoming_change_enabled) do |setting_name|- if setting_name == :enable_topic_voting_badges- DiscourseTopicVoting::EnableTopicVotingBadgesToggled.call(enabled: true)- end- end-- on(:upcoming_change_disabled) do |setting_name|- if setting_name == :enable_topic_voting_badges- DiscourseTopicVoting::EnableTopicVotingBadgesToggled.call(enabled: false)- end- end-Discourse::Application.routes.prepend doget "c/*category_slug_path_with_id/l/votes.rss" => "list#votes_feed", :format => :rssenddiff --git a/plugins/discourse-topic-voting/spec/integration/enable_topic_voting_badges_spec.rb b/plugins/discourse-topic-voting/spec/integration/topic_voting_badges_seed_spec.rbsimilarity index 86%rename from plugins/discourse-topic-voting/spec/integration/enable_topic_voting_badges_spec.rbrename to plugins/discourse-topic-voting/spec/integration/topic_voting_badges_seed_spec.rbindex 20844325fe2..effa6e0115c 100644--- a/plugins/discourse-topic-voting/spec/integration/enable_topic_voting_badges_spec.rb+++ b/plugins/discourse-topic-voting/spec/integration/topic_voting_badges_seed_spec.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-RSpec.describe "Enable Topic Voting badges by default upcoming change" do+RSpec.describe "Topic Voting badge seeds" dolet(:badge_names) { DiscourseTopicVoting::BADGE_NAMES }describe "seeding the Topic Voting badges on a new site" dodiff --git a/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/enable_topic_voting_badges_toggled_spec.rb b/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/enable_topic_voting_badges_toggled_spec.rbdeleted file mode 100644index 5d425f190e3..00000000000--- a/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/enable_topic_voting_badges_toggled_spec.rb+++ /dev/null@@ -1,26 +0,0 @@-# frozen_string_literal: true--RSpec.describe DiscourseTopicVoting::EnableTopicVotingBadgesToggled do- let(:badge_names) { DiscourseTopicVoting::BADGE_NAMES }- let(:topic_voting_badges) { Badge.where(name: badge_names) }-- describe "enabling" do- before { topic_voting_badges.update_all(enabled: false) }-- it "enables all four Topic Voting badges" do- described_class.call(enabled: true)-- expect(topic_voting_badges.where(enabled: true).count).to eq(4)- end- end-- describe "disabling" do- before { topic_voting_badges.update_all(enabled: true) }-- it "disables all four Topic Voting badges" do- described_class.call(enabled: false)-- expect(topic_voting_badges.where(enabled: false).count).to eq(4)- end- end-end