From d20b0e4582c01cfc1052335ec441342cc750ce12 Mon Sep 17 00:00:00 2001 From: ocha Date: Mon, 2 Aug 2021 01:10:19 +0900 Subject: [PATCH] =?UTF-8?q?ChannelLastSpeech.refresh!:=20MySQL=205.7?= =?UTF-8?q?=E5=90=91=E3=81=91=E3=81=AB=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/channel_last_speech_test.rb | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/models/channel_last_speech_test.rb b/test/models/channel_last_speech_test.rb index dbe7f77d..86d97c44 100644 --- a/test/models/channel_last_speech_test.rb +++ b/test/models/channel_last_speech_test.rb @@ -31,25 +31,29 @@ class ChannelLastSpeechTest < ActiveSupport::TestCase sub_test_case 'refresh!' do test 'チャンネル所属メッセージが複数ある場合、最新のメッセージが選ばれる' do - @channel.conversation_messages.delete_all + ConversationMessage.uncached do + @channel.conversation_messages.destroy_all - create(:privmsg) - privmsg_a = create(:privmsg_keyword_sw_a) - create(:privmsg_keyword_sw_k) + privmsg_a = create(:privmsg_keyword_sw_a) + create(:privmsg_keyword_sw_k) + p @channel.conversation_messages.map(&:message) - channel_last_speech = ChannelLastSpeech.refresh!(@channel) + ChannelLastSpeech.refresh!(@channel) - assert_equal(privmsg_a, @channel.last_speech) - refute_nil(channel_last_speech) + channel_last_speech = @channel.reload_channel_last_speech + refute_nil(channel_last_speech) + assert_equal(privmsg_a, channel_last_speech.conversation_message) + end end test 'チャンネル所属メッセージが存在しない場合、削除される' do - @channel.conversation_messages.delete_all + ConversationMessage.uncached do + @channel.conversation_messages.destroy_all + ChannelLastSpeech.refresh!(@channel) - channel_last_speech = ChannelLastSpeech.refresh!(@channel) - - assert_nil(@channel.last_speech) - assert_nil(channel_last_speech) + channel_last_speech = @channel.reload_channel_last_speech + assert_nil(channel_last_speech) + end end end end