fix: validate instagram story only while saving the message (#6340)
This commit is contained in:
@@ -30,6 +30,42 @@ RSpec.describe Channel::FacebookPage do
|
||||
channel.prompt_reauthorization!
|
||||
end
|
||||
end
|
||||
|
||||
context 'when fetch instagram story' do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:instagram_channel) { create(:channel_instagram_fb_page, account: account, instagram_id: 'chatwoot-app-user-id-1') }
|
||||
let!(:instagram_inbox) { create(:inbox, channel: instagram_channel, account: account, greeting_enabled: false) }
|
||||
let(:fb_object) { double }
|
||||
let(:message) { create(:message, inbox_id: instagram_inbox.id) }
|
||||
let(:instagram_message) { create(:message, :instagram_story_mention, inbox_id: instagram_inbox.id) }
|
||||
|
||||
it '#fetch_instagram_story_link' do
|
||||
allow(Koala::Facebook::API).to receive(:new).and_return(fb_object)
|
||||
allow(fb_object).to receive(:get_object).and_return(
|
||||
{ story:
|
||||
{
|
||||
mention: {
|
||||
link: 'https://www.example.com/test.jpeg',
|
||||
id: '17920786367196703'
|
||||
}
|
||||
},
|
||||
from: {
|
||||
username: 'Sender-id-1', id: 'Sender-id-1'
|
||||
},
|
||||
id: 'instagram-message-id-1234' }.with_indifferent_access
|
||||
)
|
||||
story_link = instagram_channel.fetch_instagram_story_link(message)
|
||||
expect(story_link).to eq('https://www.example.com/test.jpeg')
|
||||
end
|
||||
|
||||
it '#delete_instagram_story' do
|
||||
expect(instagram_message.attachments.count).to eq(1)
|
||||
|
||||
instagram_channel.delete_instagram_story(instagram_message)
|
||||
|
||||
expect(instagram_message.attachments.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'has a valid name' do
|
||||
|
||||
Reference in New Issue
Block a user