A platform for community discussion. Free, open, simple.
DEV: Fix spec cleanup issues for upcoming changes (#39024)
Martin Brennandd0da69c158f
diff --git a/spec/jobs/check_new_features_spec.rb b/spec/jobs/check_new_features_spec.rbindex aec7b373873..092ca4a02ab 100644--- a/spec/jobs/check_new_features_spec.rb+++ b/spec/jobs/check_new_features_spec.rb@@ -96,8 +96,6 @@ RSpec.describe Jobs::CheckNewFeatures dostub_new_features_endpoint(feature1)end- after { clear_mocked_upcoming_change_metadata }-it "notifies admins and bumps last_viewed_feature_date from the status_changed time" doNotification.destroy_all@@ -171,8 +169,6 @@ RSpec.describe Jobs::CheckNewFeatures dostub_new_features_endpoint(feature_stale)end- after { clear_mocked_upcoming_change_metadata }-it "seeds last_viewed to the UC when the fetch adds nothing newer, without notifying" doNotification.destroy_alldiff --git a/spec/lib/discourse_updates_spec.rb b/spec/lib/discourse_updates_spec.rbindex cc846c5bef1..809d2168a9a 100644--- a/spec/lib/discourse_updates_spec.rb+++ b/spec/lib/discourse_updates_spec.rb@@ -362,8 +362,6 @@ RSpec.describe DiscourseUpdates do)end- after { clear_mocked_upcoming_change_metadata }-it "marks the injected item as seen" dofreeze_timeexpect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(true)@@ -411,8 +409,6 @@ RSpec.describe DiscourseUpdates do)end- after { clear_mocked_upcoming_change_metadata }-context "when there are no permanent upcoming changes" dobefore { mock_merge_uc_metadata(:beta) }diff --git a/spec/multisite/upcoming_changes_spec.rb b/spec/multisite/upcoming_changes_spec.rbindex a62fd053879..8b08f45ef84 100644--- a/spec/multisite/upcoming_changes_spec.rb+++ b/spec/multisite/upcoming_changes_spec.rb@@ -22,7 +22,6 @@ RSpec.describe "Multisite UpcomingChanges cache", type: :multisite doDiscourse.cache.delete(UpcomingChanges.permanent_upcoming_changes_cache_key)endend- clear_mocked_upcoming_change_metadataendit "keeps current_statuses tied to each site's upcoming_change_events" dodiff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rbindex 312f7e044d0..b05e4796dc7 100644--- a/spec/requests/admin/dashboard_controller_spec.rb+++ b/spec/requests/admin/dashboard_controller_spec.rb@@ -303,8 +303,6 @@ RSpec.describe Admin::DashboardController do)end- after { clear_mocked_upcoming_change_metadata }-it "includes the permanent upcoming change in the whats-new payload" dofreeze_time doget "/admin/whats-new.json"diff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex 12f207d787d..acd5675d44c 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -342,7 +342,9 @@ module Helpersenddef mock_upcoming_change_metadata(metadata)- @original_upcoming_changes_metadata = SiteSetting.upcoming_change_metadata.dup+ # Without ||= here nested blocks would further mutate the instance var so+ # resetting in clear_mocked_upcoming_change_metadata would not work.+ @original_upcoming_changes_metadata ||= SiteSetting.upcoming_change_metadata.dup# We do this because upcoming changes are ephemeral in site settings,# so we cannot rely on them for specs. Instead we can fake some metadata@@ -354,7 +356,7 @@ module Helpersenddef clear_mocked_upcoming_change_metadata- return if @original_upcoming_changes_metadata.blank?+ return if @original_upcoming_changes_metadata.nil?SiteSetting.instance_variable_set(:@upcoming_change_metadata,