@@ -1084,4 +1084,43 @@ def create_bot_message(conversation, created_at: Time.current)
10841084 end
10851085 end
10861086 end
1087+
1088+ describe 'conversation_type' do
1089+ it 'provides type check methods' do
1090+ individual_conversation = create ( :conversation , conversation_type : :individual )
1091+ group_conversation = create ( :conversation , conversation_type : :group )
1092+
1093+ expect ( individual_conversation ) . to be_conversation_type_individual
1094+ expect ( group_conversation ) . to be_conversation_type_group
1095+ end
1096+ end
1097+
1098+ describe 'group_members association' do
1099+ it 'returns associated group members' do
1100+ conversation = create ( :conversation , conversation_type : :group )
1101+ group_member = create ( :conversation_group_member , conversation : conversation )
1102+
1103+ expect ( conversation . group_members ) . to eq ( [ group_member ] )
1104+ end
1105+ end
1106+
1107+ describe 'group_contacts association' do
1108+ it 'returns contacts through group_members' do
1109+ conversation = create ( :conversation , conversation_type : :group )
1110+ contact = create ( :contact , account : conversation . account )
1111+ create ( :conversation_group_member , conversation : conversation , contact : contact )
1112+
1113+ expect ( conversation . group_contacts ) . to eq ( [ contact ] )
1114+ end
1115+
1116+ it 'returns multiple contacts for group conversations' do
1117+ conversation = create ( :conversation , conversation_type : :group )
1118+ contact1 = create ( :contact , account : conversation . account )
1119+ contact2 = create ( :contact , account : conversation . account )
1120+ create ( :conversation_group_member , conversation : conversation , contact : contact1 )
1121+ create ( :conversation_group_member , conversation : conversation , contact : contact2 )
1122+
1123+ expect ( conversation . group_contacts ) . to contain_exactly ( contact1 , contact2 )
1124+ end
1125+ end
10871126end
0 commit comments