Skip to content

Commit

Permalink
ChannelLastSpeech.refresh!: MySQL 5.7向けにテストを調整する
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaochaocha3 committed Aug 1, 2021
1 parent 1801c1a commit d20b0e4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/models/channel_last_speech_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d20b0e4

Please sign in to comment.