connected_spec.rb 909 B

1234567891011121314151617181920212223242526272829
  1. require 'rails_helper'
  2. RSpec.describe Sequencer::Unit::Freshdesk::Connected, sequencer: :unit do
  3. context 'when checking the connection to Freshdesk' do
  4. let(:params) do
  5. {
  6. dry_run: false,
  7. import_job: instance_double(ImportJob),
  8. field_map: {},
  9. id_map: {},
  10. }
  11. end
  12. let(:response_ok) { Net::HTTPOK.new(1.0, '200', 'OK') }
  13. let(:response_unauthorized) { Net::HTTPUnauthorized.new(1.0, '401', 'Unauthorized') }
  14. it 'check for correct connection' do
  15. allow(described_class).to receive(:perform_request).with(any_args).and_return(response_ok)
  16. expect(process(params)).to eq({ connected: true })
  17. end
  18. it 'check for unauthorized connection' do
  19. allow(described_class).to receive(:perform_request).with(any_args).and_return(response_unauthorized)
  20. expect(process(params)).to eq({ connected: false })
  21. end
  22. end
  23. end