From 65091690eb248e3750bf789bb587f2ab5b4c135a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Thu, 24 Aug 2023 16:07:16 +0200 Subject: [PATCH] =?UTF-8?q?DEV:=20Don=E2=80=99t=20use=20`Chat::MessageCrea?= =?UTF-8?q?tor`=20in=20specs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As message creation is being rewritten in https://github.com/discourse/discourse/pull/22390, a new way of using the underlying service to create chat messages has been implemented in https://github.com/discourse/discourse/pull/23222. This patch uses the new fabricator option which will prevent breaking specs from this plugin when the main PR will be merged. --- spec/lib/modules/toxicity/entry_point_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/lib/modules/toxicity/entry_point_spec.rb b/spec/lib/modules/toxicity/entry_point_spec.rb index b1cdfc33..d656a7a3 100644 --- a/spec/lib/modules/toxicity/entry_point_spec.rb +++ b/spec/lib/modules/toxicity/entry_point_spec.rb @@ -38,16 +38,17 @@ describe DiscourseAi::Toxicity::EntryPoint do context "when creating a chat message" do fab!(:public_chat_channel) { Fabricate(:chat_channel) } - let(:creator) do - Chat::MessageCreator.new( - chat_channel: public_chat_channel, - user: user, - content: "This is my new test", - ) - end it "queues a job when creating a chat message" do - expect { creator.create }.to change(Jobs::ToxicityClassifyChatMessage.jobs, :size).by(1) + expect { + Fabricate( + :chat_message, + chat_channel: public_chat_channel, + user: user, + message: "This is my new test", + use_service: true, + ) + }.to change(Jobs::ToxicityClassifyChatMessage.jobs, :size).by(1) end end