From a6ae3b4f7f7766374cbce104997a3b47f98c1f48 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Thu, 3 Oct 2024 14:23:36 +0100 Subject: [PATCH] Allow setting the number of claims to allocate Updates the admin UI providing a select box for allocating a specific number of claims. --- .../admin/claims/_allocations_form.html.erb | 12 ++++---- .../admin/admin_claim_allocation_spec.rb | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/views/admin/claims/_allocations_form.html.erb b/app/views/admin/claims/_allocations_form.html.erb index f3bb44304a..b4e2b24d1b 100644 --- a/app/views/admin/claims/_allocations_form.html.erb +++ b/app/views/admin/claims/_allocations_form.html.erb @@ -1,9 +1,6 @@ -<% allocate_claim_count = @claims.where(assigned_to: nil).count > 25 ? 25 : @claims.where(assigned_to: nil).size %> -

Allocate claims

<%= form_with url: admin_bulk_allocate_path, method: :patch do |form| %> - <%= form.hidden_field :allocate_claim_count, value: allocate_claim_count %>
<%= form.select :allocate_to_policy, options_for_select(Policies.options_for_select, params[:policy]), {include_blank: "All"}, class: "govuk-select" %>
+
+ + <%= form.select :allocate_claim_count, options_for_select([5, 10, 25], params[:allocate_claim_count] || 25), {}, class: "govuk-select" %> +
-
Default: 25
- <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary", id: :allocate, disabled: allocate_claim_count.zero? %> + <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary admin-filter-group__button", id: :allocate, disabled: @claims.where(assigned_to: nil).count.zero? %>
diff --git a/spec/features/admin/admin_claim_allocation_spec.rb b/spec/features/admin/admin_claim_allocation_spec.rb index 3386e7e2d3..46f7ca6261 100644 --- a/spec/features/admin/admin_claim_allocation_spec.rb +++ b/spec/features/admin/admin_claim_allocation_spec.rb @@ -152,6 +152,36 @@ expect(page).to have_button "Allocate claims", disabled: false end + scenario "assign 5 claims to one Claim's checker" do + click_on "View claims" + + expect(@submitted_claims.size).to eq 40 + + select "Frank Yee", from: "allocate_to_team_member" + select "All", from: "allocate_to_policy" + select "10", from: "allocate_claim_count" + + click_on "Allocate claims" + + within(".govuk-flash__notice") do + expect(page).to have_text I18n.t( + "admin.allocations.bulk_allocate.success", + quantity: 10, + pluralized_or_singular_claim: "claims", + allocate_to_policy: "", + dfe_user: frank.full_name.titleize + ).squeeze(" ") + end + + @submitted_claims[0..9].each do |claim| + expect(claim.reload.assigned_to.full_name).to eq "Frank Yee" + end + + @submitted_claims[10..].each do |claim| + expect(claim.reload.assigned_to).to be_nil + end + end + scenario "assign outstanding 10 claims when 25 already allocated" do @submitted_claims.slice(0..24).each do |claim| claim.assigned_to = @signed_in_user