feat: Add Cron Jobs In Chatwoot and update installation notice (#1630)
This commit is contained in:
14
spec/jobs/internal/check_new_versions_job_spec.rb
Normal file
14
spec/jobs/internal/check_new_versions_job_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Internal::CheckNewVersionsJob, type: :job do
|
||||
subject(:job) { described_class.perform_now }
|
||||
|
||||
it 'updates the latest chatwoot version in redis' do
|
||||
version = '1.1.1'
|
||||
allow(Rails.env).to receive(:production?).and_return(true)
|
||||
allow(ChatwootHub).to receive(:latest_version).and_return(version)
|
||||
job
|
||||
expect(ChatwootHub).to have_received(:latest_version)
|
||||
expect(::Redis::Alfred.get(::Redis::Alfred::LATEST_CHATWOOT_VERSION)).to eq version
|
||||
end
|
||||
end
|
||||
15
spec/lib/chatwoot_hub_spec.rb
Normal file
15
spec/lib/chatwoot_hub_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe ChatwootHub do
|
||||
it 'get latest version from chatwoot hub' do
|
||||
version = '1.1.1'
|
||||
allow(RestClient).to receive(:get).and_return({ 'version': version }.to_json)
|
||||
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
|
||||
Reference in New Issue
Block a user