Skip to content

Commit

Permalink
Allow setting the number of claims to allocate
Browse files Browse the repository at this point in the history
Updates the admin UI providing a select box for allocating a specific
number of claims.
  • Loading branch information
rjlynch committed Oct 3, 2024
1 parent 1293079 commit a6ae3b4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/views/admin/claims/_allocations_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<% allocate_claim_count = @claims.where(assigned_to: nil).count > 25 ? 25 : @claims.where(assigned_to: nil).size %>

<h2 class="govuk-heading-m">Allocate claims</h2>

<%= form_with url: admin_bulk_allocate_path, method: :patch do |form| %>
<%= form.hidden_field :allocate_claim_count, value: allocate_claim_count %>
<div class="govuk-form-group admin-filter-group" id="allocations">
<div>
<label class="govuk-label" for="allocate_to_team_member">
Expand All @@ -17,10 +14,15 @@
</label>
<%= form.select :allocate_to_policy, options_for_select(Policies.options_for_select, params[:policy]), {include_blank: "All"}, class: "govuk-select" %>
</div>
<div>
<label class="govuk-label" for="allocate_claim_count">
Number of claims:
</label>
<%= form.select :allocate_claim_count, options_for_select([5, 10, 25], params[:allocate_claim_count] || 25), {}, class: "govuk-select" %>
</div>

<div>
<div class="govuk-label">Default: 25</div>
<%= 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? %>
</div>

<div>
Expand Down
30 changes: 30 additions & 0 deletions spec/features/admin/admin_claim_allocation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6ae3b4

Please sign in to comment.