require 'rails_helper' RSpec.describe 'Exchange integration endpoint', type: :request do before { authenticated_as(admin_with_admin_user_permissions) } let(:admin_with_admin_user_permissions) do create(:user, roles: [role_with_admin_user_permissions]) end let(:role_with_admin_user_permissions) do create(:role).tap { |role| role.permission_grant('admin.integration') } end describe 'EWS folder retrieval' do context 'when no folders found' do let(:empty_folder_list) { { folders: {} } } it 'responds with an error message' do allow(Sequencer).to receive(:process).with(any_args).and_return(empty_folder_list) post api_v1_integration_exchange_folders_path, params: {}, as: :json expect(json_response).to include('result' => 'failed').and include('message') end end end end