Restructure omni services and add Chatwoot research snapshot

This commit is contained in:
Ruslan Bakiev
2026-02-21 11:11:27 +07:00
parent edea7a0034
commit b73babbbf6
7732 changed files with 978203 additions and 32 deletions

View File

@@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.describe Widget::TokenService, type: :service do
describe 'token expiry configuration' do
let(:service) { described_class.new(payload: {}) }
before do
# Clear any existing configs to ensure test isolation
InstallationConfig.where(name: 'WIDGET_TOKEN_EXPIRY').destroy_all
end
context 'with valid configuration' do
before do
create(:installation_config, name: 'WIDGET_TOKEN_EXPIRY', value: '30')
end
it 'uses the configured value for token expiry' do
travel_to '2025-01-01' do
token = service.generate_token
decoded = JWT.decode(token, Rails.application.secret_key_base, true, algorithm: 'HS256').first
expect(decoded['iat']).to eq(Time.zone.now.to_i)
expect(decoded['exp']).to eq(Time.zone.now.to_i + 30.days.to_i)
end
end
end
context 'with empty configuration' do
before do
create(:installation_config, name: 'WIDGET_TOKEN_EXPIRY', value: '')
end
it 'uses the default expiry' do
travel_to '2025-01-01' do
token = service.generate_token
decoded = JWT.decode(token, Rails.application.secret_key_base, true, algorithm: 'HS256').first
expect(decoded['iat']).to eq(Time.zone.now.to_i)
expect(decoded['exp']).to eq(Time.zone.now.to_i + 180.days.to_i)
end
end
end
end
end