From 54d6e52607988b235bc777e567f0585a2867f74b Mon Sep 17 00:00:00 2001 From: Renato Atilio Date: Thu, 29 Aug 2024 11:39:08 -0300 Subject: [PATCH] FIX: chat mailer log noise (#28616) Fixes the log noise caused by a deprecation notice --- app/jobs/base.rb | 4 +++- plugins/chat/lib/chat/mailer.rb | 2 +- plugins/chat/spec/components/chat/mailer_spec.rb | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/jobs/base.rb b/app/jobs/base.rb index 3d064048acb..433ee2cee8d 100644 --- a/app/jobs/base.rb +++ b/app/jobs/base.rb @@ -398,11 +398,13 @@ module Jobs # Simulate the args being dumped/parsed through JSON parsed_opts = JSON.parse(JSON.dump(opts)) - Discourse.deprecate(<<~TEXT.squish, since: "2.9", drop_from: "3.0") if opts != parsed_opts + if opts != parsed_opts + Discourse.deprecate(<<~TEXT.squish, since: "2.9", drop_from: "3.0", output_in_test: true) #{klass.name} was enqueued with argument values which do not cleanly serialize to/from JSON. This means that the job will be run with slightly different values than the ones supplied to `enqueue`. Argument values should be strings, booleans, numbers, or nil (or arrays/hashes of those value types). TEXT + end opts = parsed_opts if ::Jobs.run_later? diff --git a/plugins/chat/lib/chat/mailer.rb b/plugins/chat/lib/chat/mailer.rb index 53ef482e820..21bb72256fa 100644 --- a/plugins/chat/lib/chat/mailer.rb +++ b/plugins/chat/lib/chat/mailer.rb @@ -15,7 +15,7 @@ module Chat if DiscoursePluginRegistry.apply_modifier(:chat_mailer_send_summary_to_user, true, user) Jobs.enqueue( :user_email, - type: :chat_summary, + type: "chat_summary", user_id: user.id, force_respect_seen_recently: true, ) diff --git a/plugins/chat/spec/components/chat/mailer_spec.rb b/plugins/chat/spec/components/chat/mailer_spec.rb index 89787e7879f..6feaacc16dc 100644 --- a/plugins/chat/spec/components/chat/mailer_spec.rb +++ b/plugins/chat/spec/components/chat/mailer_spec.rb @@ -23,7 +23,9 @@ describe Chat::Mailer do end def expect_enqueued - expect_enqueued_with(job:, args:) { described_class.send_unread_mentions_summary } + expect { + expect_enqueued_with(job:, args:) { described_class.send_unread_mentions_summary } + }.to_not output.to_stderr_from_any_process expect(Jobs::UserEmail.jobs.size).to eq(1) end