A platform for community discussion. Free, open, simple.
DEV: Fix deprecations in plugins specs and silence output (#39257)
Jarek Radoszbd13d858b0cf
diff --git a/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb b/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rbindex e8c47f47daa..0ad2f54aec3 100644--- a/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb+++ b/plugins/automation/app/jobs/scheduled/discourse_automation/tracker.rb@@ -67,7 +67,7 @@ module Jobspending_automation.automation.trigger!("kind" => pending_automation.automation.trigger,- "execute_at" => pending_automation.execute_at,+ "execute_at" => pending_automation.execute_at.iso8601,)pending_automation.destroy!diff --git a/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb b/plugins/chat/spec/lib/chat/channel_archive_service_spec.rbindex 40fed129255..9378935c54a 100644--- a/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb+++ b/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb@@ -237,6 +237,7 @@ describe Chat::ChannelArchiveService docreate_messages(3) && start_archive@channel_archive.update!(destination_topic_title: "Wow this is the new title :tada: :joy:")+ Discourse.expects(:warn_exception).oncedescribed_class.new(@channel_archive).executeexpect(@channel_archive.reload.complete?).to eq(false)expect(@channel_archive.reload.failed?).to eq(true)@@ -420,6 +421,7 @@ describe Chat::ChannelArchiveService do.stubs(:create_post).raises(FakeArchiveError.new("this is a test error"))+ Discourse.expects(:warn_exception).oncestub_const(Chat::ChannelArchiveService, "ARCHIVED_MESSAGES_PER_POST", 5) doexpect { described_class.new(@channel_archive).execute }.to raise_error(FakeArchiveError)enddiff --git a/plugins/chat/spec/requests/chat_controller_spec.rb b/plugins/chat/spec/requests/chat_controller_spec.rbindex 58c67622df3..6342f9e730d 100644--- a/plugins/chat/spec/requests/chat_controller_spec.rb+++ b/plugins/chat/spec/requests/chat_controller_spec.rb@@ -350,7 +350,7 @@ RSpec.describe Chat::ChatController dolet(:message3) { Fabricate(:chat_message, user: user, chat_channel: channel, message: "aw :(") }it "returns a 403 if the user can't chat" do- SiteSetting.chat_allowed_groups = nil+ SiteSetting.chat_allowed_groups = ""sign_in(user)post "/chat/#{channel.id}/quote.json",params: {diff --git a/plugins/chat/spec/requests/direct_messages_controller_spec.rb b/plugins/chat/spec/requests/direct_messages_controller_spec.rbindex ab2f2be4238..961718f89d4 100644--- a/plugins/chat/spec/requests/direct_messages_controller_spec.rb+++ b/plugins/chat/spec/requests/direct_messages_controller_spec.rb@@ -22,7 +22,7 @@ RSpec.describe Chat::DirectMessagesController dodescribe "#index" docontext "when user is not allowed to chat" do- before { SiteSetting.chat_allowed_groups = nil }+ before { SiteSetting.chat_allowed_groups = "" }it "returns a forbidden error" doget "/chat/direct_messages.json", params: { usernames: user1.username }diff --git a/plugins/discourse-affiliate/spec/db/migrate/20250722101702_enable_affiliate_if_already_installed_spec.rb b/plugins/discourse-affiliate/spec/db/migrate/20250722101702_enable_affiliate_if_already_installed_spec.rbindex 3db8e67048a..fffe45968e0 100644--- a/plugins/discourse-affiliate/spec/db/migrate/20250722101702_enable_affiliate_if_already_installed_spec.rb+++ b/plugins/discourse-affiliate/spec/db/migrate/20250722101702_enable_affiliate_if_already_installed_spec.rb@@ -5,6 +5,8 @@ require_relative "../../../db/migrate/20250722101702_enable_affiliate_if_alreadyRSpec.describe EnableAffiliateIfAlreadyInstalled dolet(:connection) { ActiveRecord::Base.connection }+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }+before do@provider = SiteSetting.providerSiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting)diff --git a/plugins/discourse-ai/lib/agents/artifact_update_strategies/diff.rb b/plugins/discourse-ai/lib/agents/artifact_update_strategies/diff.rbindex 430b99e5c8c..d7f9b5d25ce 100644--- a/plugins/discourse-ai/lib/agents/artifact_update_strategies/diff.rb+++ b/plugins/discourse-ai/lib/agents/artifact_update_strategies/diff.rb@@ -72,7 +72,7 @@ module DiscourseAi@failed_searches << { section: section, search: block[:search] }# TODO, we may need to inform caller here, LLM made a mistake which it# should correct- puts "Failed to find search: #{block[:search]}"+ Rails.logger.warn("Failed to find search: #{block[:search]}")endendupdated_content[section == :javascript ? :js : section] = contentdiff --git a/plugins/discourse-ai/lib/ai_bot/playground.rb b/plugins/discourse-ai/lib/ai_bot/playground.rbindex 5a39b8ce0ba..b81ed34bd1f 100644--- a/plugins/discourse-ai/lib/ai_bot/playground.rb+++ b/plugins/discourse-ai/lib/ai_bot/playground.rb@@ -215,12 +215,7 @@ module DiscourseAifeature_context: feature_context,)rescue => e- if Rails.env.test?- p e- puts e.backtrace[0..10]- else- raise e- end+ raise eenddef initialize(bot)diff --git a/plugins/discourse-ai/spec/db/migrate/20241031041242_migrate_sentiment_classification_result_format_spec.rb b/plugins/discourse-ai/spec/db/migrate/20241031041242_migrate_sentiment_classification_result_format_spec.rbindex 1244fa268df..9cf6051b8fc 100644--- a/plugins/discourse-ai/spec/db/migrate/20241031041242_migrate_sentiment_classification_result_format_spec.rb+++ b/plugins/discourse-ai/spec/db/migrate/20241031041242_migrate_sentiment_classification_result_format_spec.rb@@ -7,6 +7,8 @@ require Rails.root.join(RSpec.describe MigrateSentimentClassificationResultFormat dolet(:connection) { ActiveRecord::Base.connection }+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }+before doenable_current_pluginconnection.execute(<<~SQL)diff --git a/plugins/discourse-ai/spec/db/migrate/20250125162658_fix_broken_open_ai_embeddings_config_spec.rb b/plugins/discourse-ai/spec/db/migrate/20250125162658_fix_broken_open_ai_embeddings_config_spec.rbindex e3203f477e2..29dc80a8f00 100644--- a/plugins/discourse-ai/spec/db/migrate/20250125162658_fix_broken_open_ai_embeddings_config_spec.rb+++ b/plugins/discourse-ai/spec/db/migrate/20250125162658_fix_broken_open_ai_embeddings_config_spec.rb@@ -22,6 +22,8 @@ RSpec.describe FixBrokenOpenAiEmbeddingsConfig do).firstend+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }+before { enable_current_plugin }describe "#up" dodiff --git a/plugins/discourse-ai/spec/db/migrate/20250127145305_clean_unused_embedding_search_indexes_spec.rb b/plugins/discourse-ai/spec/db/migrate/20250127145305_clean_unused_embedding_search_indexes_spec.rbindex c2e657ba327..76c32801bed 100644--- a/plugins/discourse-ai/spec/db/migrate/20250127145305_clean_unused_embedding_search_indexes_spec.rb+++ b/plugins/discourse-ai/spec/db/migrate/20250127145305_clean_unused_embedding_search_indexes_spec.rb@@ -9,6 +9,8 @@ RSpec.describe CleanUnusedEmbeddingSearchIndexes dolet(:connection) { ActiveRecord::Base.connection }+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }+before { enable_current_plugin }describe "#up" dodiff --git a/plugins/discourse-ai/spec/db/migrate/20260331024139_split_translation_public_content_setting_spec.rb b/plugins/discourse-ai/spec/db/migrate/20260331024139_split_translation_public_content_setting_spec.rbindex ff995759b7d..0bedfb289b7 100644--- a/plugins/discourse-ai/spec/db/migrate/20260331024139_split_translation_public_content_setting_spec.rb+++ b/plugins/discourse-ai/spec/db/migrate/20260331024139_split_translation_public_content_setting_spec.rb@@ -27,6 +27,8 @@ RSpec.describe SplitTranslationPublicContentSetting dofab!(:public_category) { Fabricate(:category, read_restricted: false) }fab!(:private_category) { Fabricate(:category, read_restricted: true) }+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }+before { enable_current_plugin }after dodiff --git a/plugins/discourse-ai/spec/jobs/scheduled/generate_concepts_from_popular_items_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/generate_concepts_from_popular_items_spec.rbindex 1734c171c73..e9ddc8ce097 100644--- a/plugins/discourse-ai/spec/jobs/scheduled/generate_concepts_from_popular_items_spec.rb+++ b/plugins/discourse-ai/spec/jobs/scheduled/generate_concepts_from_popular_items_spec.rb@@ -205,6 +205,7 @@ RSpec.describe Jobs::GenerateConceptsFromPopularItems doendit "handles nil site setting values gracefully" do+ Discourse.expects(:deprecate).times(6)SiteSetting.inferred_concepts_daily_topics_limit = nilSiteSetting.inferred_concepts_daily_posts_limit = nilSiteSetting.inferred_concepts_min_posts = nildiff --git a/plugins/discourse-ai/spec/lib/agents/tools/setting_context_spec.rb b/plugins/discourse-ai/spec/lib/agents/tools/setting_context_spec.rbindex 60eebe80d79..2bbaa4a66e3 100644--- a/plugins/discourse-ai/spec/lib/agents/tools/setting_context_spec.rb+++ b/plugins/discourse-ai/spec/lib/agents/tools/setting_context_spec.rb@@ -4,7 +4,7 @@ def has_rg?if defined?(@has_rg)@has_rgelse- @has_rg |= system("which rg")+ @has_rg |= system("which rg", out: File::NULL)endenddiff --git a/plugins/discourse-ai/spec/tasks/scan_spec.rb b/plugins/discourse-ai/spec/tasks/scan_spec.rbindex a6876419f9e..554632f4793 100644--- a/plugins/discourse-ai/spec/tasks/scan_spec.rb+++ b/plugins/discourse-ai/spec/tasks/scan_spec.rb@@ -15,7 +15,7 @@ RSpec.describe "ai:spam rake tasks" doend_date = Time.now.to_sexpect_enqueued_with(job: :ai_spam_scan, args: { post_id: post2.id }) do- Rake::Task["ai:spam:scan_posts"].invoke(start_date, end_date)+ capture_stdout { Rake::Task["ai:spam:scan_posts"].invoke(start_date, end_date) }endexpect_not_enqueued_with(job: :ai_spam_scan, args: { post_id: post1.id })@@ -30,7 +30,7 @@ RSpec.describe "ai:spam rake tasks" doend_date = Time.now.to_sexpect_enqueued_with(job: :ai_spam_scan, args: { post_id: topic2.first_post.id }) do- Rake::Task["ai:spam:scan_topics"].invoke(start_date, end_date)+ capture_stdout { Rake::Task["ai:spam:scan_topics"].invoke(start_date, end_date) }endexpect_not_enqueued_with(job: :ai_spam_scan, args: { post_id: topic1.first_post.id })diff --git a/plugins/discourse-assign/lib/pending_assigns_reminder.rb b/plugins/discourse-assign/lib/pending_assigns_reminder.rbindex 49db18c7860..fb65e0a7c70 100644--- a/plugins/discourse-assign/lib/pending_assigns_reminder.rb+++ b/plugins/discourse-assign/lib/pending_assigns_reminder.rb@@ -52,7 +52,13 @@ class PendingAssignsReminder.joins(topic: :_custom_fields).where(topic_custom_fields: { name: CUSTOM_FIELD_NAME })- posts.find_each { |post| PostDestroyer.new(Discourse.system_user, post).destroy }+ posts.find_each do |post|+ PostDestroyer.new(+ Discourse.system_user,+ post,+ context: "cleaning up pending assigns reminder",+ ).destroy+ endenddef visible_topics(user)diff --git a/plugins/discourse-assign/lib/random_assign_utils.rb b/plugins/discourse-assign/lib/random_assign_utils.rbindex 470f96af846..b53c1b99fd1 100644--- a/plugins/discourse-assign/lib/random_assign_utils.rb+++ b/plugins/discourse-assign/lib/random_assign_utils.rb@@ -107,7 +107,7 @@ class RandomAssignUtils.assign(assigned_user, allow_self_reassign: true).then do |result|next if result[:success]- PostDestroyer.new(Discourse.system_user, post).destroy+ PostDestroyer.new(Discourse.system_user, post, context: "random assign rollback").destroyno_one!endenddiff --git a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb b/plugins/discourse-calendar/app/models/discourse_post_event/event.rbindex 0a59bbc7899..bf4ade08fa7 100644--- a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb+++ b/plugins/discourse-calendar/app/models/discourse_post_event/event.rb@@ -107,7 +107,11 @@ module DiscoursePostEventendreturn if date.blank?- Jobs.enqueue(:discourse_post_event_bump_topic, topic_id: self.post.topic_id, date: date)+ Jobs.enqueue(+ :discourse_post_event_bump_topic,+ topic_id: self.post.topic_id,+ date: date.iso8601,+ )enddef validate_reminder_unit(input)diff --git a/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb b/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rbindex 4bb8c7d558e..27be6319aef 100644--- a/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb+++ b/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb@@ -3,7 +3,7 @@describe "Data Explorer rake tasks" dobefore doRake::Task.clear- Discourse::Application.load_tasks+ silence_warnings { Discourse::Application.load_tasks }enddef make_query(sql, opts = {}, group_ids = [])diff --git a/plugins/discourse-data-explorer/spec/tasks/fix_query_ids_spec.rb b/plugins/discourse-data-explorer/spec/tasks/fix_query_ids_spec.rbindex de7f74d98b2..8c6697d719b 100644--- a/plugins/discourse-data-explorer/spec/tasks/fix_query_ids_spec.rb+++ b/plugins/discourse-data-explorer/spec/tasks/fix_query_ids_spec.rb@@ -3,7 +3,7 @@describe "fix query ids rake task" dobefore doRake::Task.clear- Discourse::Application.load_tasks+ silence_warnings { Discourse::Application.load_tasks }endlet(:query_name) { "Awesome query" }diff --git a/plugins/discourse-presence/spec/integration/presence_spec.rb b/plugins/discourse-presence/spec/integration/presence_spec.rbindex 74fd8f57694..28507494c03 100644--- a/plugins/discourse-presence/spec/integration/presence_spec.rb+++ b/plugins/discourse-presence/spec/integration/presence_spec.rb@@ -66,7 +66,7 @@ RSpec.describe "discourse-presence" doendit "handles category moderators for edit" do- SiteSetting.edit_all_post_groups = nil+ SiteSetting.edit_all_post_groups = ""p = Fabricate(:post, topic: private_topic, user: private_topic.user)c = PresenceChannel.new("/discourse-presence/edit/#{p.id}")diff --git a/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb b/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rbindex cbc814d2dfb..74b9a58e59a 100644--- a/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb+++ b/plugins/discourse-subscriptions/spec/requests/subscribe_controller_spec.rb@@ -158,7 +158,7 @@ RSpec.describe DiscourseSubscriptions::SubscribeController doendit "shows all purchases if campaign product not set" do- SiteSetting.discourse_subscriptions_campaign_product = nil+ SiteSetting.discourse_subscriptions_campaign_product = ""get "/s/contributors.json"diff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex 23229cac3c0..b05b3a84b56 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -191,7 +191,12 @@ module HelpersFile.write("#{repo_dir}/#{name}", data)system("git -C #{repo_dir} add #{name}", exception: true)end- system("git -C #{repo_dir} commit -q -am 'first commit'", exception: false)+ system(+ "git -C #{repo_dir} commit -q -am 'first commit'",+ out: File::NULL,+ err: File::NULL,+ exception: false,+ )repo_dirend