connected_spec.rb 990 B

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