Skip to content

Commit

Permalink
AP-5701: Update has_other_proceedings controller
Browse files Browse the repository at this point in the history
Update the view to display the correct text if all four
proceedings have been chosen.  Update the controller tests
to ensure it works.  Record new VCR cassettes as we have to
make an additional call to the LFA endpoint
  • Loading branch information
colinbruce committed Jan 31, 2025
1 parent acd954e commit 9d83831
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 9 deletions.
14 changes: 10 additions & 4 deletions app/views/providers/has_other_proceedings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
url: providers_legal_aid_application_has_other_proceedings_path,
method: :patch,
local: true) do |form| %>
<%= page_template page_title: t(".page_title"), template: :basic, form: do %>
<% page_title_prefix = @form.remaining_proceedings.zero? ? ".no_more_proceedings" : "" %>
<%= page_template page_title: t("#{page_title_prefix}.page_title"), template: :basic, form: do %>
<% if @legal_aid_application.proceedings.any? %>
<h1 class="govuk-heading-xl"><%= t(".existing", count: pluralize(@legal_aid_application.proceedings.count, "proceeding").to_s) %></h1>
<%= govuk_summary_list do |summary_list| %>
Expand Down Expand Up @@ -35,9 +36,14 @@
<% end %>
<% end %>

<%= form.govuk_collection_radio_buttons :has_other_proceeding, yes_no_options, :value, :label,
legend: { text: content_for(:page_title), tag: "h2", size: "m" } do %>
<%= govuk_inset_text(text: t(".inset")) %>
<% if @form.remaining_proceedings.zero? %>
<h2 class="govuk-heading-l"><%= content_for(:page_title) %></h2>
<p class="govuk-body"><%= t(".no_more_proceedings.caption") %></p>
<% else %>
<%= form.govuk_collection_radio_buttons :has_other_proceeding, yes_no_options, :value, :label,
legend: { text: content_for(:page_title), tag: "h2", size: "m" } do %>
<%= govuk_inset_text(text: t(".inset")) %>
<% end %>
<% end %>

<%= next_action_buttons(form:, show_draft: true) %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,9 @@ en:
existing: You have added %{count}
inset: You will only be shown the proceedings that can be added to the ones you have selected.
remove: Remove
no_more_proceedings:
page_title: You have added all the allowed proceedings
caption: No more proceedings can be added to the ones you have chosen
providers:
show:
account_number: Account number
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions spec/requests/providers/has_other_proceedings_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Providers::HasOtherProceedingsController do
RSpec.describe Providers::HasOtherProceedingsController, :vcr do
let(:legal_aid_application) do
create(:legal_aid_application,
:with_proceedings,
Expand All @@ -24,18 +24,27 @@
end

describe "GET /providers/:application_id/has_other_proceedings" do
before do
get providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
end

it "shows the page" do
get providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
expect(response).to have_http_status(:ok)
expect(response.body).to include(I18n.t("providers.has_other_proceedings.show.page_title"))
end

it "shows the current number of proceedings" do
get providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
expect(response.body).to include("You have added 2 proceedings")
end

context "when all available proceedings have been added" do
before do
allow(LegalFramework::ProceedingTypes::All).to receive(:call).and_raise(LegalFramework::ProceedingTypes::All::NoMatchingProceedingsFoundError)
end

it "renders the limited page" do
get providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
expect(response.body).to include "You have added all the allowed proceedings"
end
end
end

describe "PATCH /providers/:application_id/has_other_proceedings" do
Expand Down

0 comments on commit 9d83831

Please sign in to comment.