diff --git a/enterprise/app/controllers/api/v1/accounts/agent_capacity_policies_controller.rb b/enterprise/app/controllers/api/v1/accounts/agent_capacity_policies_controller.rb index d6d166ee5..9ece78762 100644 --- a/enterprise/app/controllers/api/v1/accounts/agent_capacity_policies_controller.rb +++ b/enterprise/app/controllers/api/v1/accounts/agent_capacity_policies_controller.rb @@ -27,7 +27,7 @@ class Api::V1::Accounts::AgentCapacityPoliciesController < Api::V1::Accounts::En params.require(:agent_capacity_policy).permit( :name, :description, - exclusion_rules: [:overall_capacity, { hours: [], days: [] }] + exclusion_rules: [:exclude_older_than_hours, { excluded_labels: [] }] ) end diff --git a/spec/enterprise/controllers/api/v1/accounts/agent_capacity_policies_controller_spec.rb b/spec/enterprise/controllers/api/v1/accounts/agent_capacity_policies_controller_spec.rb index d6b171fe8..691891027 100644 --- a/spec/enterprise/controllers/api/v1/accounts/agent_capacity_policies_controller_spec.rb +++ b/spec/enterprise/controllers/api/v1/accounts/agent_capacity_policies_controller_spec.rb @@ -103,7 +103,10 @@ RSpec.describe 'Agent Capacity Policies API', type: :request do agent_capacity_policy: { name: 'Test Policy', description: 'Test Description', - exclusion_rules: { overall_capacity: 10 } + exclusion_rules: { + excluded_labels: %w[urgent spam], + exclude_older_than_hours: 24 + } } } @@ -115,6 +118,10 @@ RSpec.describe 'Agent Capacity Policies API', type: :request do expect(response).to have_http_status(:success) expect(response.parsed_body['name']).to eq('Test Policy') expect(response.parsed_body['description']).to eq('Test Description') + expect(response.parsed_body['exclusion_rules']).to eq({ + 'excluded_labels' => %w[urgent spam], + 'exclude_older_than_hours' => 24 + }) end it 'returns validation errors for invalid data' do @@ -165,6 +172,28 @@ RSpec.describe 'Agent Capacity Policies API', type: :request do expect(response).to have_http_status(:success) expect(response.parsed_body['name']).to eq('Updated Policy') end + + it 'updates exclusion rules when administrator' do + params = { + agent_capacity_policy: { + exclusion_rules: { + excluded_labels: %w[vip priority], + exclude_older_than_hours: 48 + } + } + } + + put "/api/v1/accounts/#{account.id}/agent_capacity_policies/#{agent_capacity_policy.id}", + params: params, + headers: administrator.create_new_auth_token, + as: :json + + expect(response).to have_http_status(:success) + expect(response.parsed_body['exclusion_rules']).to eq({ + 'excluded_labels' => %w[vip priority], + 'exclude_older_than_hours' => 48 + }) + end end end