From 7a7de71c398f682e2c0e634d4dbf16c93939200a Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Thu, 7 May 2026 20:00:54 +0700 Subject: [PATCH] Revert "test(telegram): fix business-chat send-attachments spec" This reverts commit 461292fb2bd4135f0a560b64fa24a3f502e8bc3a. --- .../telegram/send_attachments_service_spec.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/spec/services/telegram/send_attachments_service_spec.rb b/spec/services/telegram/send_attachments_service_spec.rb index 14fb22896..f9c625780 100644 --- a/spec/services/telegram/send_attachments_service_spec.rb +++ b/spec/services/telegram/send_attachments_service_spec.rb @@ -3,17 +3,13 @@ require 'rails_helper' RSpec.describe Telegram::SendAttachmentsService do describe '#perform' do let(:channel) { create(:channel_telegram) } - # Channel#chat_id and #business_connection_id read from conversation.additional_attributes, - # so set the values there directly — stubbing the let(:channel) instance doesn't affect - # the service's message.inbox.channel reference (different object instance). - let(:conversation) do - create(:conversation, inbox: channel.inbox, additional_attributes: { 'chat_id' => 'chat123' }) - end - let(:message) { build(:message, conversation: conversation) } + let(:message) { build(:message, conversation: create(:conversation, inbox: channel.inbox)) } let(:service) { described_class.new(message: message) } let(:telegram_api_url) { channel.telegram_api_url } before do + allow(channel).to receive(:chat_id).and_return('chat123') + stub_request(:post, "#{telegram_api_url}/sendMediaGroup") .to_return(status: 200, body: { ok: true, result: [{ message_id: 'media' }] }.to_json, headers: { 'Content-Type' => 'application/json' }) @@ -45,11 +41,7 @@ RSpec.describe Telegram::SendAttachmentsService do end context 'when this is business chat' do - before do - conversation.update!(additional_attributes: conversation.additional_attributes.merge( - 'business_connection_id' => 'eooW3KF5WB5HxTD7T826' - )) - end + before { allow(channel).to receive(:business_connection_id).and_return('eooW3KF5WB5HxTD7T826') } it 'sends all types of attachments in seperate groups and returns the last successful message ID from the batch' do attach_files(message)