fix: Handle PermissionDeniedError for Dialogflow processor (#8252)
This commit is contained in:
@@ -162,10 +162,17 @@ describe Integrations::Dialogflow::ProcessorService do
|
||||
allow(session_client).to receive(:detect_intent).and_return({ session: session, query_input: query_input })
|
||||
end
|
||||
|
||||
it 'returns indented response' do
|
||||
it 'returns intended response' do
|
||||
response = processor.send(:get_response, conversation.contact_inbox.source_id, message.content)
|
||||
expect(response[:query_input][:text][:text]).to eq(message)
|
||||
expect(response[:query_input][:text][:language_code]).to eq('en-US')
|
||||
end
|
||||
|
||||
it 'disables the hook if permission errors are thrown' do
|
||||
allow(session_client).to receive(:detect_intent).and_raise(Google::Cloud::PermissionDeniedError)
|
||||
|
||||
expect { processor.send(:get_response, conversation.contact_inbox.source_id, message.content) }
|
||||
.to change(hook, :status).from('enabled').to('disabled')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,22 @@ RSpec.describe AdministratorNotifications::ChannelNotificationsMailer do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'dialogflow disconnect' do
|
||||
let(:mail) { described_class.with(account: account).dialogflow_disconnect.deliver_now }
|
||||
|
||||
it 'renders the subject' do
|
||||
expect(mail.subject).to eq('Your Dialogflow integration was disconnected')
|
||||
end
|
||||
|
||||
it 'renders the content' do
|
||||
expect(mail.body).to include('Your Dialogflow integration was disconnected because of permission issues.')
|
||||
end
|
||||
|
||||
it 'renders the receiver email' do
|
||||
expect(mail.to).to eq([administrator.email])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'facebook_disconnect' do
|
||||
before do
|
||||
stub_request(:post, /graph.facebook.com/)
|
||||
|
||||
Reference in New Issue
Block a user