Skip to content

Commit

Permalink
Merge pull request #3269 from DFE-Digital/CAPT-1834/claim-allocations…
Browse files Browse the repository at this point in the history
…-dropdown

CAPT 1834/claim allocations dropdown
  • Loading branch information
rjlynch authored Oct 8, 2024
2 parents 3e5dca1 + b11140f commit 4bb7f84
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 23 deletions.
43 changes: 20 additions & 23 deletions app/views/admin/claims/_allocations_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<% 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 %>
<%= form_with url: admin_bulk_allocate_path, method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
<div class="govuk-form-group admin-filter-group" id="allocations">
<div>
<label class="govuk-label" for="allocate_to_team_member">
Team members:
</label>
<%= form.select :allocate_to_team_member, options_for_select(DfeSignIn::User.options_for_select, params[:allocate_to_team_member]), {}, class: "govuk-select" %>
</div>
<div>
<label class="govuk-label" for="allocate_to_policy">
Policy:
</label>
<%= form.select :allocate_to_policy, options_for_select(Policies.options_for_select, params[:policy]), {include_blank: "All"}, class: "govuk-select" %>
</div>
<%= form.govuk_select(
:allocate_to_team_member,
options_for_select(DfeSignIn::User.options_for_select, params[:allocate_to_team_member]),
label: { text: "Team members:" }
) %>

<%= form.govuk_select(
:allocate_to_policy,
options_for_select(Policies.options_for_select, params[:policy]),
options: { include_blank: "All" },
label: { text: "Policy:" }
) %>

<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? %>
</div>
<%= form.govuk_select(
:allocate_claim_count,
options_for_select([5, 10, 25], params[:allocate_claim_count] || 25),
label: { text: "Number of claims:" }
) %>

<div>
<%= form.submit "Unallocate claims", class: "govuk-button govuk-button--secondary admin-filter-group__button", id: :unallocate, formaction: admin_bulk_deallocate_path %>
</div>
<%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary", id: :allocate, disabled: @claims.where(assigned_to: nil).count.zero? %>
<%= form.submit "Unallocate claims", class: "govuk-button govuk-button--secondary", id: :unallocate, formaction: admin_bulk_deallocate_path %>
</div>
<% end %>
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 4bb7f84

Please sign in to comment.