2021-01-11 12:04:41 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ChatwootHub do
|
|
|
|
it 'get latest version from chatwoot hub' do
|
|
|
|
version = '1.1.1'
|
2021-06-07 11:56:08 +00:00
|
|
|
allow(RestClient).to receive(:get).and_return({ version: version }.to_json)
|
2021-01-11 12:04:41 +00:00
|
|
|
expect(described_class.latest_version).to eq version
|
|
|
|
expect(RestClient).to have_received(:get).with(described_class::BASE_URL, { params: described_class.instance_config })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil when chatwoot hub is down' do
|
|
|
|
allow(RestClient).to receive(:get).and_raise(ExceptionList::REST_CLIENT_EXCEPTIONS.sample)
|
|
|
|
expect(described_class.latest_version).to eq nil
|
|
|
|
end
|
|
|
|
end
|