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