Compare commits

...
2 changed files with 15 additions and 1 deletions
+11
View File
@@ -53,6 +53,7 @@ class Inbox < ApplicationRecord
validates :out_of_office_message, length: { maximum: Limits::OUT_OF_OFFICE_MESSAGE_MAX_LENGTH }
validates :greeting_message, length: { maximum: Limits::GREETING_MESSAGE_MAX_LENGTH }
validate :ensure_valid_max_assignment_limit
validate :ensure_inbox_limit, on: :create
belongs_to :account
belongs_to :portal, optional: true
@@ -237,6 +238,16 @@ class Inbox < ApplicationRecord
# overridden in enterprise/app/models/enterprise/inbox.rb
end
def ensure_inbox_limit
return unless account
inbox_limit = account.usage_limits[:inboxes]
return if inbox_limit.nil?
return unless account.inboxes.count >= inbox_limit.to_i
errors.add(:base, 'Account inbox limit exceeded. Upgrade to a higher plan')
end
def delete_round_robin_agents
::AutoAssignment::InboxRoundRobinService.new(inbox: self).clear_queue
end
+4 -1
View File
@@ -280,7 +280,10 @@ RSpec.describe Captain::BaseTaskService do
describe '#prompt_from_file' do
it 'reads prompt from file' do
allow(Rails.root).to receive(:join).and_return(instance_double(Pathname, read: 'Test prompt content'))
allow(Rails.root).to receive(:join).and_call_original
allow(Rails.root).to receive(:join)
.with('lib/integrations/openai/openai_prompts', 'test.liquid')
.and_return(instance_double(Pathname, read: 'Test prompt content'))
expect(service.send(:prompt_from_file, 'test')).to eq('Test prompt content')
end
end