Skip to content

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

DEV: Silence expected error/debug output in core specs (#39247)

Jarek Radosz63cb32f7a517
diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rake
index a9265da4168..5651bbc1e5a 100644
--- a/lib/tasks/plugin.rake
+++ b/lib/tasks/plugin.rake
@@ -100,7 +100,7 @@ def update_plugin(plugin)
`git -C '#{plugin_path}' branch -m master main`
end
- `git -C '#{plugin_path}' branch -u origin/main main`
+ `git -C '#{plugin_path}' branch -q -u origin/main main`
end
update_status = system("git -C '#{plugin_path}' pull --quiet --no-rebase")
diff --git a/spec/db/migrate/20260106060807_add_slug_to_tags_spec.rb b/spec/db/migrate/20260106060807_add_slug_to_tags_spec.rb
index d0c72f91ca6..c6ff51c73d6 100644
--- a/spec/db/migrate/20260106060807_add_slug_to_tags_spec.rb
+++ b/spec/db/migrate/20260106060807_add_slug_to_tags_spec.rb
@@ -3,6 +3,8 @@
require Rails.root.join("db/migrate/20260106060807_add_slug_to_tags.rb")
describe AddSlugToTags do
+ around { |example| ActiveRecord::Migration.suppress_messages { example.run } }
+
def reset_slug_column
DB.exec("DROP INDEX IF EXISTS index_tags_on_lower_slug")
DB.exec("DROP INDEX IF EXISTS index_tags_on_slug")
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 25e46b09a78..7b49a351a4a 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -338,6 +338,15 @@ RSpec.configure do |config|
Sidekiq.default_configuration.error_handlers.clear
+ # No-op handler to suppress Sidekiq's `p ["!!!!!", ex]` fallback.
+ Sidekiq.default_configuration.error_handlers << ->(_ex, _ctx, _config) {}
+
+ # Quiet seed-fu output produced by specs that call `Model.seed`.
+ SeedFu.quiet = true
+
+ # json-schema's MultiJSON support is deprecated.
+ JSON::Validator.use_multi_json = false
+
# Ugly, but needed until we have a user creator
User.skip_callback(:create, :after, :ensure_in_trust_level_group)
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 6d984a6c769..5a2c1d8e3e5 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -1208,7 +1208,7 @@ RSpec.describe TopicsController do
end
it "returns 403 when group is not allow listed" do
- SiteSetting.change_post_ownership_allowed_groups = nil
+ SiteSetting.change_post_ownership_allowed_groups = ""
post "/t/#{topic_allowed_user_can_see.id}/change-owner.json",
params: {
diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rb
index efab54e5f17..c3950e8ca90 100644
--- a/spec/requests/webhooks_controller_spec.rb
+++ b/spec/requests/webhooks_controller_spec.rb
@@ -182,6 +182,7 @@ RSpec.describe WebhooksController do
post "/webhooks/sendgrid.json",
headers: {
+ "Content-Type" => "application/json",
"X-Twilio-Email-Event-Webhook-Signature" =>
"MEUCIGHQVtGj+Y3LkG9fLcxf3qfI10QysgDWmMOVmxG0u6ZUAiEAyBiXDWzM+uOe5W0JuG+luQAbPIqHh89M15TluLtEZtM=",
"X-Twilio-Email-Event-Webhook-Timestamp" => "1600112502",
@@ -198,6 +199,7 @@ RSpec.describe WebhooksController do
post "/webhooks/sendgrid.json",
headers: {
+ "Content-Type" => "application/json",
"X-Twilio-Email-Event-Webhook-Signature" =>
"MEUCIQCtIHJeH93Y+qpYeWrySphQgpNGNr/U+UyUlBkU6n7RAwIgJTz2C+8a8xonZGi6BpSzoQsbVRamr2nlxFDWYNH3j/0=",
"X-Twilio-Email-Event-Webhook-Timestamp" => "1600112502",
@@ -213,6 +215,7 @@ RSpec.describe WebhooksController do
post "/webhooks/sendgrid.json",
headers: {
+ "Content-Type" => "application/json",
"X-Twilio-Email-Event-Webhook-Signature" =>
"MEUCIQCtIHJeH93Y+qpYeWrySphQgpNGNr/U+UyUlBkU6n7RAwIgJTz2C+8a8xonZGi6BpSzoQsbVRamr2nlxFDWYNH3j/0=",
"X-Twilio-Email-Event-Webhook-Timestamp" => "1600112502",
@@ -229,6 +232,7 @@ RSpec.describe WebhooksController do
post "/webhooks/sendgrid.json",
headers: {
+ "Content-Type" => "application/json",
"X-Twilio-Email-Event-Webhook-Timestamp" => "1600112492",
},
params:
@@ -243,6 +247,7 @@ RSpec.describe WebhooksController do
post "/webhooks/sendgrid.json",
headers: {
+ "Content-Type" => "application/json",
"X-Twilio-Email-Event-Webhook-Signature" =>
"MEUCIGHQVtGj+Y3LkG9fLcxf3qfI10QysgDWmMOVmxG0u6ZUAiEAyBiXDWzM+uOe5W0JuG+luQAbPIqHh89M15TluLtEZtM=",
},
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index a4249585aeb..23229cac3c0 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -200,7 +200,7 @@ module Helpers
system("git -C #{path} fetch -q", exception: true)
branch = `git -C #{path} rev-parse --abbrev-ref HEAD`.strip
raise "no branch in setup_remote_upstream" if branch.blank?
- system("git -C #{path} branch -u origin/#{branch}", exception: true)
+ system("git -C #{path} branch -q -u origin/#{branch}", exception: true)
system("git -C #{path} remote set-head origin #{branch}", exception: true)
end
diff --git a/spec/tasks/migrate_advanced_search_banner_to_welcome_banner_spec.rb b/spec/tasks/migrate_advanced_search_banner_to_welcome_banner_spec.rb
index 850b8c08b23..6db22beda84 100644
--- a/spec/tasks/migrate_advanced_search_banner_to_welcome_banner_spec.rb
+++ b/spec/tasks/migrate_advanced_search_banner_to_welcome_banner_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe "tasks/migrate_advanced_search_banner_to_welcome_banner" do
before do
Rake::Task.clear
- Discourse::Application.load_tasks
+ silence_warnings { Discourse::Application.load_tasks }
end
describe "#validate_and_get_db" do
@@ -21,7 +21,8 @@ RSpec.describe "tasks/migrate_advanced_search_banner_to_welcome_banner" do
default_db = RailsMultisite::ConnectionManagement::DEFAULT
RailsMultisite::ConnectionManagement.stubs(:has_db?).with(db).returns(false)
- result = validate_and_get_db(db)
+ result = nil
+ expect { result = validate_and_get_db(db) }.to output(/not found/).to_stdout
expect(result).to eq(default_db)
end
@@ -168,7 +169,8 @@ RSpec.describe "tasks/migrate_advanced_search_banner_to_welcome_banner" do
it "does nothing when theme is disabled" do
disabled_theme = Fabricate(:theme, component: true, enabled: false)
- result = enable_welcome_banner(disabled_theme)
+ result = nil
+ expect { result = enable_welcome_banner(disabled_theme) }.to output(/is disabled/).to_stdout
expect(result).to be_nil
end
@@ -176,7 +178,10 @@ RSpec.describe "tasks/migrate_advanced_search_banner_to_welcome_banner" do
it "skips when theme has no parent relations" do
orphan_theme = Fabricate(:theme, component: true, enabled: true)
- result = enable_welcome_banner(orphan_theme)
+ result = nil
+ expect { result = enable_welcome_banner(orphan_theme) }.to output(
+ /is not included in any of your themes/,
+ ).to_stdout
expect(result).to be_nil
end