A platform for community discussion. Free, open, simple.
DEV: Remove enable_upcoming_changes global setting gate (#38360)
Martin Brennana15f83133a8b
diff --git a/app/jobs/scheduled/check_upcoming_changes.rb b/app/jobs/scheduled/check_upcoming_changes.rbindex 722efb169ab..0e85d0d2ded 100644--- a/app/jobs/scheduled/check_upcoming_changes.rb+++ b/app/jobs/scheduled/check_upcoming_changes.rb@@ -5,8 +5,6 @@ module Jobsevery 20.minutesdef execute(args)- return if !SiteSetting.enable_upcoming_changes-site = RailsMultisite::ConnectionManagement.current_dbverbose_log(site,diff --git a/app/serializers/admin_detailed_user_serializer.rb b/app/serializers/admin_detailed_user_serializer.rbindex 06c24c60b67..a26d9e2fccb 100644--- a/app/serializers/admin_detailed_user_serializer.rb+++ b/app/serializers/admin_detailed_user_serializer.rb@@ -194,6 +194,6 @@ class AdminDetailedUserSerializer < AdminUserSerializerenddef include_upcoming_changes_stats?- SiteSetting.enable_upcoming_changes && scope.is_staff?+ scope.is_staff?endenddiff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rbindex c24810036c8..b1c6600f867 100644--- a/app/serializers/current_user_serializer.rb+++ b/app/serializers/current_user_serializer.rb@@ -172,7 +172,7 @@ class CurrentUserSerializer < BasicUserSerializerenddef include_has_new_upcoming_changes?- SiteSetting.enable_upcoming_changes && object.staff?+ object.staff?enddef has_new_upcoming_changesdiff --git a/app/services/problem_check/upcoming_change_stable_opted_out.rb b/app/services/problem_check/upcoming_change_stable_opted_out.rbindex fea11c3b53b..7212a9d7117 100644--- a/app/services/problem_check/upcoming_change_stable_opted_out.rb+++ b/app/services/problem_check/upcoming_change_stable_opted_out.rb@@ -5,8 +5,6 @@ class ProblemCheck::UpcomingChangeStableOptedOut < ProblemCheckself.targets = -> { SiteSetting.upcoming_change_site_settings }def call- return no_problem if !SiteSetting.enable_upcoming_changes-# If the site setting is enabled, then the change is opted in, either# manually or automatically, so we skip it.return no_problem if SiteSetting.send(target)diff --git a/app/services/upcoming_changes/toggle.rb b/app/services/upcoming_changes/toggle.rbindex 6796d52f927..bb4cffc77c8 100644--- a/app/services/upcoming_changes/toggle.rb+++ b/app/services/upcoming_changes/toggle.rb@@ -44,15 +44,7 @@ class UpcomingChanges::Toggledef toggle(params:, guardian:, options:)context[:previous_value] = SiteSetting.public_send(params.setting_name)- # TODO (martin) Remove this once we release upcoming changes,- # otherwise it will be confusing for people to see log messages- # about upcoming changes via "What's new?" experimental toggles- # before we update that UI.- if SiteSetting.enable_upcoming_changes- SiteSetting.send("#{params.setting_name}=", params.enabled)- else- SiteSetting.public_send("#{params.setting_name}=", params.enabled)- end+ SiteSetting.send("#{params.setting_name}=", params.enabled)enddef clear_groups_if_disallowed(params:)@@ -68,21 +60,15 @@ class UpcomingChanges::Toggleenddef log_change(params:, guardian:, options:)- if SiteSetting.enable_upcoming_changes- StaffActionLogger.new(guardian.user).log_upcoming_change_toggle(- params.setting_name,- context[:previous_value],- params.enabled,- { context: I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled") },- )- else- SiteSetting.log(params.setting_name, params.enabled, context[:previous_value], guardian.user)- end+ StaffActionLogger.new(guardian.user).log_upcoming_change_toggle(+ params.setting_name,+ context[:previous_value],+ params.enabled,+ { context: I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled") },+ )enddef log_event(params:, guardian:, options:)- return unless SiteSetting.enable_upcoming_changes-UpcomingChangeEvent.create!(event_type: params.enabled ? :manual_opt_in : :manual_opt_out,upcoming_change_name: params.setting_name,diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex faa0f8c025f..2b3208de1b4 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2764,7 +2764,6 @@ en:content_localization_crawler_param: "Serve localized content to web crawlers when 'content localization enabled' and 'set locale from param' is enabled. The list of supported locales is defined in 'content localization supported locales'."content_localization_use_default_locale_when_unsupported: "Serve localized content in the site's default locale to users whose preferred language is not listed in 'content localization supported locales'."content_localization_allow_author_localization: "Allow authors update localizations of their own topics and posts via the post menu."- enable_upcoming_changes: "Enable upcoming changes"fake_upcoming_change: "This is a fake upcoming change for testing purposes. No need to translate this string."floating_dismiss_topics_on_mobile: "Shows a floating 'Dismiss...' button on mobile for the topic list for easier access and to free up space in the top of the topic list"rename_faq_to_guidelines: "This change renames the FAQ page to Guidelines. The FAQ page will still be available at /faq. The 'faq url' setting works as before."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 46c68afc3f2..3d548abc96d 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4293,10 +4293,6 @@ experimental:default: truehidden: trueclient: true- enable_upcoming_changes:- default: false- hidden: true- client: truefloating_dismiss_topics_on_mobile:default: falsehidden: truediff --git a/db/migrate/20260309032553_remove_enable_upcoming_changes_site_setting.rb b/db/migrate/20260309032553_remove_enable_upcoming_changes_site_setting.rbnew file mode 100644index 00000000000..00d45c2edc1--- /dev/null+++ b/db/migrate/20260309032553_remove_enable_upcoming_changes_site_setting.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++class RemoveEnableUpcomingChangesSiteSetting < ActiveRecord::Migration[8.0]+ def up+ execute "DELETE FROM site_settings WHERE name = 'enable_upcoming_changes'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/frontend/discourse/admin/templates/admin-user/index.gjs b/frontend/discourse/admin/templates/admin-user/index.gjsindex 40a94df1d06..a5f7b82e14d 100644--- a/frontend/discourse/admin/templates/admin-user/index.gjs+++ b/frontend/discourse/admin/templates/admin-user/index.gjs@@ -934,11 +934,7 @@ export default <template>{{/if}}{{#if- (and- @controller.currentUser.staff- @controller.model.upcoming_changes_stats- @controller.siteSettings.enable_upcoming_changes- )+ (and @controller.currentUser.staff @controller.model.upcoming_changes_stats)}}<section class="details"><h1>{{i18n "admin.user.upcoming_changes.title"}}</h1>diff --git a/frontend/discourse/app/lib/sidebar/admin-sidebar.js b/frontend/discourse/app/lib/sidebar/admin-sidebar.jsindex 523b8cac6a7..4170e9d78e9 100644--- a/frontend/discourse/app/lib/sidebar/admin-sidebar.js+++ b/frontend/discourse/app/lib/sidebar/admin-sidebar.js@@ -431,23 +431,21 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {]);}- if (siteSettings.enable_upcoming_changes) {- const rootSection = this.adminNavManager.findSection("root");- const linkExists = rootSection?.links.some(- (link) => link.name === "admin_upcoming_changes"- );- if (!linkExists) {- this.adminNavManager.amendLinksToSection("root", [- {- name: "admin_upcoming_changes",- route: "adminConfig.upcomingChanges",- label: "admin.config.upcoming_changes.title",- description: "admin.config.upcoming_changes.header_description",- icon: "flask",- keywords: "admin.config.upcoming_changes.keywords",- },- ]);- }+ const rootSection = this.adminNavManager.findSection("root");+ const linkExists = rootSection?.links.some(+ (link) => link.name === "admin_upcoming_changes"+ );+ if (!linkExists) {+ this.adminNavManager.amendLinksToSection("root", [+ {+ name: "admin_upcoming_changes",+ route: "adminConfig.upcomingChanges",+ label: "admin.config.upcoming_changes.title",+ description: "admin.config.upcoming_changes.header_description",+ icon: "flask",+ keywords: "admin.config.upcoming_changes.keywords",+ },+ ]);}for (const [sectionName, additionalLinks] of Object.entries(diff --git a/lib/upcoming_changes.rb b/lib/upcoming_changes.rbindex ebf71fa9985..f2162184e5a 100644--- a/lib/upcoming_changes.rb+++ b/lib/upcoming_changes.rb@@ -91,6 +91,12 @@ module UpcomingChanges).order(created_at: :desc)end+ # We dynamically determine if an upcoming change is enabled+ # or disabled based on the current status of the change as well+ # as whether the admin has manually toggled the change.+ #+ # @param change_setting_name [Symbol] The name of the upcoming change+ # @return [Boolean]def self.resolved_value(change_setting_name)# An admin has modified the setting and a value is stored# in the database, since the default for upcoming changes@@ -125,6 +131,15 @@ module UpcomingChangesSiteSetting.site_setting_group_ids[change_setting_name].presence || []end+ # Checks if a given upcoming change is enabled for a user,+ # which can be either enabled for everyone, enabled for certain groups,+ # or disabled for everyone. The user's group membership is used to determine+ # if the upcoming change is enabled for them if the upcoming change is+ # enabled for certain groups.+ #+ # @param change_setting_name [Symbol] The name of the upcoming change+ # @param user [User] The user to check if the upcoming change is enabled for+ # @return [Boolean]def self.enabled_for_user?(change_setting_name, user)change_setting_name = change_setting_name.to_symsetting_enabled = SiteSetting.public_send(change_setting_name)@@ -143,6 +158,38 @@ module UpcomingChangessetting_enabledend+ # Calculates the current state of all upcoming changes for a given user,+ # including the reason why a change is or isn't enabled for them, and+ # if it's due to group membership, which groups are relevant.+ #+ # The acting_guardian is used to determine group visibility. This is+ # mostly used to show a list of upcoming changes for a user in the admin+ # interface.+ #+ # @param user [User] The user to get the upcoming changes for+ # @param acting_guardian [Guardian] The current user's guardian+ # @return [Array<Hash>]+ #+ # @example+ # stats_for_user(user: user, acting_guardian: admin)+ # # => [+ # # {+ # # name: "new_feature",+ # # humanized_name: "New Feature",+ # # description: "This is a new feature",+ # # enabled: true,+ # # specific_groups: ["Group 1", "Group 2"],+ # # reason: :in_specific_groups+ # # },+ # # {+ # # name: "another_feature",+ # # humanized_name: "Another Feature",+ # # description: "This is another feature",+ # # enabled: false,+ # # specific_groups: [],+ # # reason: :enabled_for_no_one+ # # },+ # # ]def self.stats_for_user(user:, acting_guardian:)guardian_visible_group_ids = Group.visible_groups(acting_guardian.user).pluck(:id)user_belonging_to_group_ids = user.belonging_to_group_ids@@ -182,6 +229,19 @@ module UpcomingChangesendend+ # For a given setting, we need to determine the enabled for value+ # for the UI based on the setting value, and if the setting is enabled+ # for certain groups, we need the actual group records to display in the UI.+ # Mostly a utility method.+ #+ # @param setting_name [Symbol] The name of the setting+ # @param setting_value [Boolean] The value of the setting+ # @param upcoming_change_selected_groups [Hash] A hash of group ids to group names+ # across all upcoming changes.+ # @return [Hash] The enabled for value and the setting groups+ #+ # @example+ # enabled_for_with_groups(:new_feature, true, { 1 => "Group 1", 2 => "Group 2" })def self.enabled_for_with_groups(setting_name, setting_value, upcoming_change_selected_groups)group_ids_for_setting = SiteSetting.site_setting_group_ids[setting_name]setting_groups =diff --git a/spec/jobs/scheduled/check_upcoming_changes_spec.rb b/spec/jobs/scheduled/check_upcoming_changes_spec.rbindex ed4edf58ab8..ade145dd4ae 100644--- a/spec/jobs/scheduled/check_upcoming_changes_spec.rb+++ b/spec/jobs/scheduled/check_upcoming_changes_spec.rb@@ -2,308 +2,287 @@RSpec.describe Jobs::CheckUpcomingChanges dodescribe "#execute" do- context "when enable_upcoming_changes is disabled" do- before do- SiteSetting.enable_upcoming_changes = false- SiteSetting.upcoming_change_verbose_logging = true- end+ fab!(:admin)- it "does not log" do+ before do+ SiteSetting.upcoming_change_verbose_logging = true+ SiteSetting.promote_upcoming_changes_on_status = :stable+ end++ context "when there are no upcoming changes" do+ before { SiteSetting.stubs(:upcoming_change_site_settings).returns([]) }++ it "logs start message and that no changes are present" dotrack_log_messages do |logger|described_class.new.execute({})- expect(logger.infos).to be_empty- expect(logger.errors).to be_empty+ expect(logger.infos.join("\n")).to include(+ "Starting change tracker and promotion notifier for upcoming changes",+ )+ expect(logger.infos.join("\n")).to include("No upcoming changes present.")endendend- context "when enable_upcoming_changes is enabled" do- fab!(:admin)-+ context "when there are upcoming changes to track" dobefore do- SiteSetting.enable_upcoming_changes = true- SiteSetting.upcoming_change_verbose_logging = true- SiteSetting.promote_upcoming_changes_on_status = :stable+ mock_upcoming_change_metadata(+ {+ enable_upload_debug_mode: {+ impact: "other,developers",+ status: :beta,+ impact_type: "other",+ impact_role: "developers",+ },+ enable_user_tips: {+ impact: "feature,all_members",+ status: :alpha,+ impact_type: "feature",+ impact_role: "all_members",+ },+ },+ )end- context "when there are no upcoming changes" do- before { SiteSetting.stubs(:upcoming_change_site_settings).returns([]) }+ it "synchronizes execution using DistributedMutex" do+ DistributedMutex+ .expects(:synchronize)+ .with("check_upcoming_changes_default", validity: 10.minutes)+ .yields+ described_class.new.execute({})+ end++ context "when changes are newly added" do+ before do+ UpcomingChangeEvent.where(+ upcoming_change_name: %i[enable_upload_debug_mode enable_user_tips],+ ).delete_all+ end- it "logs start message and that no changes are present" do+ it "logs added changes" dotrack_log_messages do |logger|described_class.new.execute({})expect(logger.infos.join("\n")).to include(- "Starting change tracker and promotion notifier for upcoming changes",+ "Added upcoming change 'enable_upload_debug_mode'",)- expect(logger.infos.join("\n")).to include("No upcoming changes present.")+ expect(logger.infos.join("\n")).to include("Added upcoming change 'enable_user_tips'")endendend- context "when there are upcoming changes to track" do+ context "when admins are notified about an available change" dobefore do- mock_upcoming_change_metadata(- {- enable_upload_debug_mode: {- impact: "other,developers",- status: :beta,- impact_type: "other",- impact_role: "developers",- },- enable_user_tips: {- impact: "feature,all_members",- status: :alpha,- impact_type: "feature",- impact_role: "all_members",- },- },- )+ UpcomingChangeEvent.where(+ upcoming_change_name: %i[enable_upload_debug_mode enable_user_tips],+ ).delete_allend- it "synchronizes execution using DistributedMutex" do- DistributedMutex- .expects(:synchronize)- .with("check_upcoming_changes_default", validity: 10.minutes)- .yields- described_class.new.execute({})+ it "logs that admins were notified" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Notified site admins about added upcoming change 'enable_upload_debug_mode'",+ )+ endend- context "when changes are newly added" do- before do- UpcomingChangeEvent.where(- upcoming_change_name: %i[enable_upload_debug_mode enable_user_tips],- ).delete_all+ it "does not log notification for changes that do not meet status threshold" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).not_to include(+ "Notified site admins about added upcoming change 'enable_user_tips'",+ )end+ end+ end- it "logs added changes" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Added upcoming change 'enable_upload_debug_mode'",- )- expect(logger.infos.join("\n")).to include("Added upcoming change 'enable_user_tips'")- end- end+ context "when changes are removed" do+ before do+ UpcomingChangeEvent.create!(event_type: :added, upcoming_change_name: :old_removed_change)end- context "when admins are notified about an available change" do- before do- UpcomingChangeEvent.where(- upcoming_change_name: %i[enable_upload_debug_mode enable_user_tips],- ).delete_all- end+ after { UpcomingChangeEvent.where(upcoming_change_name: :old_removed_change).delete_all }- it "logs that admins were notified" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Notified site admins about added upcoming change 'enable_upload_debug_mode'",- )- end+ it "logs removed changes" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Removed upcoming change 'old_removed_change'",+ )end+ end+ end- it "does not log notification for changes that do not meet status threshold" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).not_to include(- "Notified site admins about added upcoming change 'enable_user_tips'",- )- end- end+ context "when status changes for an existing change" do+ before do+ UpcomingChangeEvent.create!(+ event_type: :added,+ upcoming_change_name: :enable_upload_debug_mode,+ )+ UpcomingChangeEvent.create!(+ event_type: :status_changed,+ upcoming_change_name: :enable_upload_debug_mode,+ event_data: {+ "previous_value" => nil,+ "new_value" => "alpha",+ },+ )+ UpcomingChangeEvent.create!(+ event_type: :admins_notified_available_change,+ upcoming_change_name: :enable_upload_debug_mode,+ )end- context "when changes are removed" do- before do- UpcomingChangeEvent.create!(- event_type: :added,- upcoming_change_name: :old_removed_change,+ it "logs status changes" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Status changed for upcoming change 'enable_upload_debug_mode' from alpha to beta",)end+ end+ end+ end- after { UpcomingChangeEvent.where(upcoming_change_name: :old_removed_change).delete_all }+ context "when the UpcomingChanges::Track service has an unexpected failure" do+ before do+ mock_upcoming_change_metadata(+ {+ enable_upload_debug_mode: {+ impact: "other,developers",+ status: :stable,+ impact_type: "other",+ impact_role: "developers",+ },+ },+ )+ end- it "logs removed changes" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Removed upcoming change 'old_removed_change'",- )+ it "logs the error" do+ failing_track =+ Class.new(UpcomingChanges::Track) do+ def run!+ context.fail(error: "Simulated failure")+ raise Service::Base::Failure.new(context)endend- end- context "when status changes for an existing change" do- before do- UpcomingChangeEvent.create!(- event_type: :added,- upcoming_change_name: :enable_upload_debug_mode,- )- UpcomingChangeEvent.create!(- event_type: :status_changed,- upcoming_change_name: :enable_upload_debug_mode,- event_data: {- "previous_value" => nil,- "new_value" => "alpha",- },- )- UpcomingChangeEvent.create!(- event_type: :admins_notified_available_change,- upcoming_change_name: :enable_upload_debug_mode,+ stub_const(UpcomingChanges, "Track", failing_track) do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.errors.join("\n")).to include(+ "Failed to track upcoming changes, an unexpected error occurred.",)end-- it "logs status changes" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Status changed for upcoming change 'enable_upload_debug_mode' from alpha to beta",- )- end- endendend+ end- context "when the UpcomingChanges::Track service has an unexpected failure" do- before do- mock_upcoming_change_metadata(- {- enable_upload_debug_mode: {- impact: "other,developers",- status: :stable,- impact_type: "other",- impact_role: "developers",- },+ context "when notifying promotions" do+ before do+ mock_upcoming_change_metadata(+ {+ enable_upload_debug_mode: {+ impact: "other,developers",+ status: :stable,+ impact_type: "other",+ impact_role: "developers",},- )- end-- it "logs the error" do- failing_track =- Class.new(UpcomingChanges::Track) do- def run!- context.fail(error: "Simulated failure")- raise Service::Base::Failure.new(context)- end- end-- stub_const(UpcomingChanges, "Track", failing_track) do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.errors.join("\n")).to include(- "Failed to track upcoming changes, an unexpected error occurred.",- )- end- end- end+ enable_user_tips: {+ impact: "feature,all_members",+ status: :beta,+ impact_type: "feature",+ impact_role: "all_members",+ },+ show_user_menu_avatars: {+ impact: "feature,all_members",+ status: :permanent,+ impact_type: "feature",+ impact_role: "all_members",+ },+ },+ )end- context "when notifying promotions" do+ context "when the change meets promotion criteria" dobefore do- mock_upcoming_change_metadata(- {- enable_upload_debug_mode: {- impact: "other,developers",- status: :stable,- impact_type: "other",- impact_role: "developers",- },- enable_user_tips: {- impact: "feature,all_members",- status: :beta,- impact_type: "feature",- impact_role: "all_members",- },- show_user_menu_avatars: {- impact: "feature,all_members",- status: :permanent,- impact_type: "feature",- impact_role: "all_members",- },- },+ UpcomingChangeEvent.create!(+ event_type: :added,+ upcoming_change_name: :enable_upload_debug_mode,+ )+ UpcomingChangeEvent.create!(+ event_type: :admins_notified_available_change,+ upcoming_change_name: :enable_upload_debug_mode,+ )+ UpcomingChangeEvent.where(+ upcoming_change_name: :enable_upload_debug_mode,+ event_type: :admins_notified_automatic_promotion,+ ).delete_all++ UpcomingChangeEvent.create!(+ event_type: :added,+ upcoming_change_name: :show_user_menu_avatars,+ )+ UpcomingChangeEvent.create!(+ event_type: :admins_notified_available_change,+ upcoming_change_name: :show_user_menu_avatars,+ )+ UpcomingChangeEvent.create!(+ event_type: :admins_notified_automatic_promotion,+ upcoming_change_name: :show_user_menu_avatars,+ acting_user: Discourse.system_user,)end- context "when the change meets promotion criteria" do- before do- UpcomingChangeEvent.create!(- event_type: :added,- upcoming_change_name: :enable_upload_debug_mode,- )- UpcomingChangeEvent.create!(- event_type: :admins_notified_available_change,- upcoming_change_name: :enable_upload_debug_mode,- )- UpcomingChangeEvent.where(- upcoming_change_name: :enable_upload_debug_mode,- event_type: :admins_notified_automatic_promotion,- ).delete_all-- UpcomingChangeEvent.create!(- event_type: :added,- upcoming_change_name: :show_user_menu_avatars,- )- UpcomingChangeEvent.create!(- event_type: :admins_notified_available_change,- upcoming_change_name: :show_user_menu_avatars,- )- UpcomingChangeEvent.create!(- event_type: :admins_notified_automatic_promotion,- upcoming_change_name: :show_user_menu_avatars,- acting_user: Discourse.system_user,+ it "logs promotion notification" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Notified site admins about promotion of 'enable_upload_debug_mode'",)end-- it "logs promotion notification" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Notified site admins about promotion of 'enable_upload_debug_mode'",- )- end- endend+ end- context "when the change does not meet promotion criteria" do- before { SiteSetting.promote_upcoming_changes_on_status = :never }-- it "does not log promotion" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).not_to include(- "Notified site admins about promotion of 'enable_upload_debug_mode'",- )- end- end+ context "when the change does not meet promotion criteria" do+ before { SiteSetting.promote_upcoming_changes_on_status = :never }- it "logs the error" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Failed to notify about promotion of 'enable_upload_debug_mode': Setting enable_upload_debug_mode does not meet or exceed the promotion status",- )- end+ it "does not log promotion" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).not_to include(+ "Notified site admins about promotion of 'enable_upload_debug_mode'",+ )endend- context "when notifying about permanent changes" do- before do- UpcomingChangeEvent.create!(- event_type: :added,- upcoming_change_name: :show_user_menu_avatars,- )- UpcomingChangeEvent.create!(- event_type: :admins_notified_available_change,- upcoming_change_name: :show_user_menu_avatars,+ it "logs the error" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Failed to notify about promotion of 'enable_upload_debug_mode': Setting enable_upload_debug_mode does not meet or exceed the promotion status",)end+ end+ end- it "logs promotion of permanent change" do- track_log_messages do |logger|- described_class.new.execute({})- expect(logger.infos.join("\n")).to include(- "Notified site admins about promotion of 'show_user_menu_avatars'",- )- end+ context "when notifying about permanent changes" do+ before do+ UpcomingChangeEvent.create!(+ event_type: :added,+ upcoming_change_name: :show_user_menu_avatars,+ )+ UpcomingChangeEvent.create!(+ event_type: :admins_notified_available_change,+ upcoming_change_name: :show_user_menu_avatars,+ )+ end++ it "logs promotion of permanent change" do+ track_log_messages do |logger|+ described_class.new.execute({})+ expect(logger.infos.join("\n")).to include(+ "Notified site admins about promotion of 'show_user_menu_avatars'",+ )endendend@@ -311,7 +290,6 @@ RSpec.describe Jobs::CheckUpcomingChanges docontext "when upcoming_change_verbose_logging is disabled" dobefore do- SiteSetting.enable_upcoming_changes = trueSiteSetting.upcoming_change_verbose_logging = falseSiteSetting.stubs(:upcoming_change_site_settings).returns([])enddiff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 9101de6579b..51135cab3af 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -3814,8 +3814,6 @@ RSpec.describe User dolet(:admin_guardian) { Guardian.new(admin_user) }before do- SiteSetting.enable_upcoming_changes = true-mock_upcoming_change_metadata({enable_upload_debug_mode: {diff --git a/spec/requests/admin/config/upcoming_changes_controller_spec.rb b/spec/requests/admin/config/upcoming_changes_controller_spec.rbindex b5b4320b6f8..ddcc5ba803b 100644--- a/spec/requests/admin/config/upcoming_changes_controller_spec.rb+++ b/spec/requests/admin/config/upcoming_changes_controller_spec.rb@@ -4,8 +4,6 @@ RSpec.describe Admin::Config::UpcomingChangesController dofab!(:admin)fab!(:user)- before { SiteSetting.enable_upcoming_changes = true }-describe "#index" dobefore domock_upcoming_change_metadata(diff --git a/spec/requests/api/schemas/json/admin_user_response.json b/spec/requests/api/schemas/json/admin_user_response.jsonindex da3bd2b6a9d..8f6bbab6e64 100644--- a/spec/requests/api/schemas/json/admin_user_response.json+++ b/spec/requests/api/schemas/json/admin_user_response.json@@ -500,6 +500,46 @@},"include_ip": {"type": "boolean"+ },+ "upcoming_changes_stats": {+ "type": "array",+ "items": {+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "type": {+ "type": "string",+ "enum": ["object"]+ },+ "properties": {+ "name": { "type": "string" },+ "humanized_name": { "type": "string" },+ "description": { "type": "string" },+ "enabled": { "type": "boolean" },+ "specific_groups": {+ "type": "array",+ "items": { "type": "string" }+ },+ "reason": {+ "type": "string",+ "enum": [+ "enabled_for_everyone",+ "enabled_for_no_one",+ "in_specific_groups",+ "not_in_specific_groups"+ ]+ }+ }+ },+ "required": [+ "name",+ "humanized_name",+ "description",+ "enabled",+ "specific_groups",+ "reason"+ ]+ }}},"required": [diff --git a/spec/services/problem_check/upcoming_change_stable_opted_out_spec.rb b/spec/services/problem_check/upcoming_change_stable_opted_out_spec.rbindex 4e7833d4c18..f2dce91b5e7 100644--- a/spec/services/problem_check/upcoming_change_stable_opted_out_spec.rb+++ b/spec/services/problem_check/upcoming_change_stable_opted_out_spec.rb@@ -19,47 +19,35 @@ RSpec.describe ProblemCheck::UpcomingChangeStableOptedOut do)end- context "when enable_upcoming_changes is disabled" do- before { SiteSetting.enable_upcoming_changes = false }+ context "when upcoming change is enabled (opted in)" do+ before { SiteSetting.enable_upload_debug_mode = true }it { expect(check).to be_chill_about_it }end- context "when enable_upcoming_changes is enabled" do- before { SiteSetting.enable_upcoming_changes = true }+ context "when upcoming change is stable and not opted in" do+ before { SiteSetting.enable_upload_debug_mode = false }- context "when upcoming change is enabled (opted in)" do- before { SiteSetting.enable_upload_debug_mode = true }-- it { expect(check).to be_chill_about_it }- end-- context "when upcoming change is stable and not opted in" do- before { SiteSetting.enable_upload_debug_mode = false }-- it do- expect(check).to have_a_problem.with_priority("low").with_target(- "enable_upload_debug_mode",- )- end+ it do+ expect(check).to have_a_problem.with_priority("low").with_target("enable_upload_debug_mode")end+ end- context "when upcoming change is not yet stable and not opted in" do- before do- mock_upcoming_change_metadata(- {- enable_upload_debug_mode: {- impact: "other,developers",- status: :alpha,- impact_type: "other",- impact_role: "developers",- },+ context "when upcoming change is not yet stable and not opted in" do+ before do+ mock_upcoming_change_metadata(+ {+ enable_upload_debug_mode: {+ impact: "other,developers",+ status: :alpha,+ impact_type: "other",+ impact_role: "developers",},- )- end-- it { expect(check).to be_chill_about_it }+ },+ )end++ it { expect(check).to be_chill_about_it }endendenddiff --git a/spec/services/upcoming_changes/toggle_spec.rb b/spec/services/upcoming_changes/toggle_spec.rbindex 46370192b51..72fcb9ca370 100644--- a/spec/services/upcoming_changes/toggle_spec.rb+++ b/spec/services/upcoming_changes/toggle_spec.rb@@ -37,151 +37,8 @@ RSpec.describe UpcomingChanges::Toggle docontext "when everything's ok" doit { is_expected.to run_successfully }- context "when enable_upcoming_changes is disabled" do- let(:setting_name) { :display_local_time_in_user_card }-- context "when log_change is true" do- let(:options) { { log_change: true } }-- context "when enabling the setting" do- let(:enabled) { true }-- before { SiteSetting.display_local_time_in_user_card = false }-- it "enables the specified setting" do- expect { result }.to change { SiteSetting.display_local_time_in_user_card }.to(true)- end-- it "creates an entry in the staff action logs" do- expect { result }.to change {- UserHistory.where(- action: UserHistory.actions[:change_site_setting],- subject: "display_local_time_in_user_card",- ).count- }.by(1)- end-- it "logs the correct previous value" do- result- history =- UserHistory.find_by(- action: UserHistory.actions[:change_site_setting],- subject: "display_local_time_in_user_card",- )- expect(history.previous_value).to eq("false")- expect(history.new_value).to eq("true")- end-- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end-- it "triggers the upcoming_change_enabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_enabled }-- expect(events.first[:params]).to eq([setting_name.to_s])- end- end-- context "when disabling the setting" do- let(:enabled) { false }-- before { SiteSetting.display_local_time_in_user_card = true }-- it "disables the specified setting" do- expect { result }.to change { SiteSetting.display_local_time_in_user_card }.to(false)- end-- it "creates an entry in the staff action logs" do- expect { result }.to change {- UserHistory.where(- action: UserHistory.actions[:change_site_setting],- subject: "display_local_time_in_user_card",- ).count- }.by(1)- end-- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end-- it "triggers the upcoming_change_disabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_disabled }-- expect(events.first[:params]).to eq([setting_name.to_s])- end- end- end-- context "when log_change is false" do- let(:options) { { log_change: false } }-- context "when enabling the setting" do- let(:enabled) { true }-- before { SiteSetting.display_local_time_in_user_card = false }-- it "enables the specified setting" do- expect { result }.to change { SiteSetting.display_local_time_in_user_card }.to(true)- end-- it "does not create an entry in the staff action logs" do- expect { result }.not_to change {- UserHistory.where(- action: UserHistory.actions[:change_site_setting],- subject: "display_local_time_in_user_card",- ).count- }- end-- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end- end-- context "when disabling the setting" do- let(:enabled) { false }-- before { SiteSetting.display_local_time_in_user_card = true }-- it "disables the specified setting" do- expect { result }.to change { SiteSetting.display_local_time_in_user_card }.to(false)- end-- it "does not create an entry in the staff action logs" do- expect { result }.not_to change {- UserHistory.where(- action: UserHistory.actions[:change_site_setting],- subject: "display_local_time_in_user_card",- ).count- }- end-- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end-- it "triggers the upcoming_change_disabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_disabled }-- expect(events.first[:params]).to eq([setting_name.to_s])- end- end- end- end-context "when disallow_enabled_for_groups is true" dobefore do- SiteSetting.enable_upcoming_changes = truemock_upcoming_change_metadata(enable_form_templates: {impact: "feature,all_members",@@ -234,160 +91,156 @@ RSpec.describe UpcomingChanges::Toggle doendend- context "when enable_upcoming_changes is enabled" do- before { SiteSetting.enable_upcoming_changes = true }-- context "when log_change is true" do- let(:options) { { log_change: true } }-- context "when enabling the setting" do- let(:enabled) { true }-- before { SiteSetting.enable_form_templates = false }-- it "enables the specified setting" do- expect { result }.to change { SiteSetting.enable_form_templates }.to(true)- end-- it "creates an entry in the staff action logs with correct context" do- expect { result }.to change {- UserHistory.where(- action: UserHistory.actions[:upcoming_change_toggled],- subject: "enable_form_templates",- ).count- }.by(1)-- expect(UserHistory.last.context).to eq(- I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled"),- )- end-- it "creates an UpcomingChangeEvent with manual_opt_in event_type" do- expect { result }.to change {- UpcomingChangeEvent.where(- event_type: :manual_opt_in,- upcoming_change_name: "enable_form_templates",- ).count- }.by(1)- end-- it "triggers the upcoming_change_enabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_enabled }-- expect(events.first[:params]).to eq([setting_name.to_s])- end+ context "when log_change is true" do+ let(:options) { { log_change: true } }++ context "when enabling the setting" do+ let(:enabled) { true }++ before { SiteSetting.enable_form_templates = false }++ it "enables the specified setting" do+ expect { result }.to change { SiteSetting.enable_form_templates }.to(true)+ end++ it "creates an entry in the staff action logs with correct context" do+ expect { result }.to change {+ UserHistory.where(+ action: UserHistory.actions[:upcoming_change_toggled],+ subject: "enable_form_templates",+ ).count+ }.by(1)++ expect(UserHistory.last.context).to eq(+ I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled"),+ )+ end++ it "creates an UpcomingChangeEvent with manual_opt_in event_type" do+ expect { result }.to change {+ UpcomingChangeEvent.where(+ event_type: :manual_opt_in,+ upcoming_change_name: "enable_form_templates",+ ).count+ }.by(1)+ end++ it "triggers the upcoming_change_enabled event" do+ events =+ DiscourseEvent+ .track_events { result }+ .select { |e| e[:event_name] == :upcoming_change_enabled }++ expect(events.first[:params]).to eq([setting_name.to_s])+ end+ end++ context "when disabling the setting" do+ let(:enabled) { false }++ before { SiteSetting.enable_form_templates = true }++ it "disables the specified setting" do+ expect { result }.to change { SiteSetting.enable_form_templates }.to(false)+ end++ it "creates an entry in the staff action logs with correct context" do+ expect { result }.to change {+ UserHistory.where(+ action: UserHistory.actions[:upcoming_change_toggled],+ subject: "enable_form_templates",+ ).count+ }.by(1)++ expect(UserHistory.last.context).to eq(+ I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled"),+ )end- context "when disabling the setting" do- let(:enabled) { false }-- before { SiteSetting.enable_form_templates = true }-- it "disables the specified setting" do- expect { result }.to change { SiteSetting.enable_form_templates }.to(false)- end-- it "creates an entry in the staff action logs with correct context" do- expect { result }.to change {- UserHistory.where(- action: UserHistory.actions[:upcoming_change_toggled],- subject: "enable_form_templates",- ).count- }.by(1)-- expect(UserHistory.last.context).to eq(- I18n.t("staff_action_logs.upcoming_changes.log_manually_toggled"),- )- end-- it "creates an UpcomingChangeEvent with manual_opt_out event_type" do- expect { result }.to change {- UpcomingChangeEvent.where(- event_type: :manual_opt_out,- upcoming_change_name: "enable_form_templates",- ).count- }.by(1)- end-- it "triggers the upcoming_change_disabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_disabled }-- expect(events.first[:params]).to eq([setting_name.to_s])- end+ it "creates an UpcomingChangeEvent with manual_opt_out event_type" do+ expect { result }.to change {+ UpcomingChangeEvent.where(+ event_type: :manual_opt_out,+ upcoming_change_name: "enable_form_templates",+ ).count+ }.by(1)+ end++ it "triggers the upcoming_change_disabled event" do+ events =+ DiscourseEvent+ .track_events { result }+ .select { |e| e[:event_name] == :upcoming_change_disabled }++ expect(events.first[:params]).to eq([setting_name.to_s])endend+ end- context "when log_change is false" do- let(:options) { { log_change: false } }+ context "when log_change is false" do+ let(:options) { { log_change: false } }- context "when enabling the setting" do- let(:enabled) { true }+ context "when enabling the setting" do+ let(:enabled) { true }- before { SiteSetting.enable_form_templates = false }+ before { SiteSetting.enable_form_templates = false }- it "enables the specified setting" do- expect { result }.to change { SiteSetting.enable_form_templates }.to(true)- end+ it "enables the specified setting" do+ expect { result }.to change { SiteSetting.enable_form_templates }.to(true)+ end- it "does not create an entry in the staff action logs" do- expect { result }.not_to change {- UserHistory.where(- action: UserHistory.actions[:upcoming_change_toggled],- subject: "enable_form_templates",- ).count- }- end+ it "does not create an entry in the staff action logs" do+ expect { result }.not_to change {+ UserHistory.where(+ action: UserHistory.actions[:upcoming_change_toggled],+ subject: "enable_form_templates",+ ).count+ }+ end- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end+ it "does not create an UpcomingChangeEvent" do+ expect { result }.not_to change { UpcomingChangeEvent.count }+ end- it "triggers the upcoming_change_enabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_enabled }+ it "triggers the upcoming_change_enabled event" do+ events =+ DiscourseEvent+ .track_events { result }+ .select { |e| e[:event_name] == :upcoming_change_enabled }- expect(events.first[:params]).to eq([setting_name.to_s])- end+ expect(events.first[:params]).to eq([setting_name.to_s])end+ end- context "when disabling the setting" do- let(:enabled) { false }+ context "when disabling the setting" do+ let(:enabled) { false }- before { SiteSetting.enable_form_templates = true }+ before { SiteSetting.enable_form_templates = true }- it "disables the specified setting" do- expect { result }.to change { SiteSetting.enable_form_templates }.to(false)- end+ it "disables the specified setting" do+ expect { result }.to change { SiteSetting.enable_form_templates }.to(false)+ end- it "does not create an entry in the staff action logs" do- expect { result }.not_to change {- UserHistory.where(- action: UserHistory.actions[:upcoming_change_toggled],- subject: "enable_form_templates",- ).count- }- end+ it "does not create an entry in the staff action logs" do+ expect { result }.not_to change {+ UserHistory.where(+ action: UserHistory.actions[:upcoming_change_toggled],+ subject: "enable_form_templates",+ ).count+ }+ end- it "does not create an UpcomingChangeEvent" do- expect { result }.not_to change { UpcomingChangeEvent.count }- end+ it "does not create an UpcomingChangeEvent" do+ expect { result }.not_to change { UpcomingChangeEvent.count }+ end- it "triggers the upcoming_change_disabled event" do- events =- DiscourseEvent- .track_events { result }- .select { |e| e[:event_name] == :upcoming_change_disabled }+ it "triggers the upcoming_change_disabled event" do+ events =+ DiscourseEvent+ .track_events { result }+ .select { |e| e[:event_name] == :upcoming_change_disabled }- expect(events.first[:params]).to eq([setting_name.to_s])- end+ expect(events.first[:params]).to eq([setting_name.to_s])endendenddiff --git a/spec/system/admin_sidebar_navigation_spec.rb b/spec/system/admin_sidebar_navigation_spec.rbindex 21def99df0d..6e2560c2c20 100644--- a/spec/system/admin_sidebar_navigation_spec.rb+++ b/spec/system/admin_sidebar_navigation_spec.rb@@ -66,6 +66,7 @@ describe "Admin | Sidebar Navigation", type: :system doI18n.t("admin_js.admin.config.site_settings.title"),I18n.t("js.sidebar.sections.community.links.review.content"),I18n.t("admin_js.admin.config.whats_new.title"),+ I18n.t("admin_js.admin.config.upcoming_changes.title"),],)end@@ -106,6 +107,7 @@ describe "Admin | Sidebar Navigation", type: :system doI18n.t("admin_js.admin.config.site_settings.title"),I18n.t("js.sidebar.sections.community.links.review.content"),I18n.t("admin_js.admin.config.whats_new.title"),+ I18n.t("admin_js.admin.config.upcoming_changes.title"),]expect(page).to have_selector(".sidebar-section-link-content-text",diff --git a/spec/system/admin_upcoming_changes_spec.rb b/spec/system/admin_upcoming_changes_spec.rbindex 1d1ce0168ff..439d8028f6f 100644--- a/spec/system/admin_upcoming_changes_spec.rb+++ b/spec/system/admin_upcoming_changes_spec.rb@@ -5,8 +5,6 @@ describe "Admin upcoming changes", type: :system dolet(:upcoming_changes_page) { PageObjects::Pages::AdminUpcomingChanges.new }before do- SiteSetting.enable_upcoming_changes = true-mock_upcoming_change_metadata({enable_upload_debug_mode: {diff --git a/spec/system/admin_user_spec.rb b/spec/system/admin_user_spec.rbindex fe21e344f1c..8b791dc7cd2 100644--- a/spec/system/admin_user_spec.rb+++ b/spec/system/admin_user_spec.rb@@ -66,8 +66,6 @@ describe "Admin User Page", type: :system dofab!(:group2) { Fabricate(:group, name: "test_group_2") }before do- SiteSetting.enable_upcoming_changes = true-mock_upcoming_change_metadata({enable_upload_debug_mode: {diff --git a/spec/system/member_upcoming_changes_spec.rb b/spec/system/member_upcoming_changes_spec.rbindex 57b8eef49f1..b2464844033 100644--- a/spec/system/member_upcoming_changes_spec.rb+++ b/spec/system/member_upcoming_changes_spec.rb@@ -6,8 +6,6 @@ RSpec.describe "Member upcoming changes", type: :system dolet(:upcoming_changes_page) { PageObjects::Pages::AdminUpcomingChanges.new }before do- SiteSetting.enable_upcoming_changes = true-mock_upcoming_change_metadata({enable_upload_debug_mode: {