fix: Update account limit selection logic (#6149)

This commit is contained in:
Pranav Raj S
2022-12-29 19:37:36 -08:00
parent 02a687b226
commit 297e144f33
2 changed files with 27 additions and 1 deletions

View File

@@ -38,5 +38,27 @@ RSpec.describe Account do
}
)
end
it 'returns max limits from global config if account limit is absent' do
account.update(limits: { agents: '' })
expect(account.usage_limits).to eq(
{
agents: 20,
inboxes: ChatwootApp.max_limit
}
)
end
it 'returns max limits from app limit if account limit and installation config is absent' do
account.update(limits: { agents: '' })
InstallationConfig.where(name: 'ACCOUNT_AGENTS_LIMIT').update(value: '')
expect(account.usage_limits).to eq(
{
agents: ChatwootApp.max_limit,
inboxes: ChatwootApp.max_limit
}
)
end
end
end