trabajo-afectivo/spec/lib/sequencer/unit/freshdesk/connected_spec.rb

32 lines
985 B
Ruby
Raw Permalink Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2021-05-25 12:30:12 +00:00
require 'rails_helper'
RSpec.describe Sequencer::Unit::Freshdesk::Connected, sequencer: :unit do
context 'when checking the connection to Freshdesk' do
let(:params) do
{
dry_run: false,
import_job: instance_double(ImportJob),
field_map: {},
id_map: {},
}
end
let(:response_ok) { Net::HTTPOK.new(1.0, '200', 'OK') }
let(:response_unauthorized) { Net::HTTPUnauthorized.new(1.0, '401', 'Unauthorized') }
it 'check for correct connection' do
allow(described_class).to receive(:perform_request).with(any_args).and_return(response_ok)
expect(process(params)).to eq({ connected: true })
end
it 'check for unauthorized connection' do
allow(described_class).to receive(:perform_request).with(any_args).and_return(response_unauthorized)
expect(process(params)).to eq({ connected: false })
end
end
end