Skip to content

Commit

Permalink
Merge pull request #6508 from ministryofjustice/ap-4910/interrupt-flo…
Browse files Browse the repository at this point in the history
…w-in-progress

AP-4910: Interrupt flow for in-progress applications
  • Loading branch information
colinbruce authored Apr 4, 2024
2 parents 91f49f9 + 31268ca commit 338fddc
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 3 deletions.
7 changes: 7 additions & 0 deletions app/controllers/providers/interrupt/blocks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Providers
module Interrupt
class BlocksController < ProviderBaseController
def show; end
end
end
end
17 changes: 16 additions & 1 deletion app/helpers/providers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ def link_to_application(text, legal_aid_application)
end

def url_for_application(legal_aid_application)
name = legal_aid_application.provider_step.presence || :proceedings_types
name = if legal_aid_application.expired?
:providers_blocked
else
legal_aid_application.provider_step.presence || :proceedings_types
end

Flow::ProviderFlowService.new(
legal_aid_application:,
Expand All @@ -25,4 +29,15 @@ def journey_start_path(legal_aid_application)
legal_aid_application:,
)
end

def tag_colour(legal_aid_application)
case legal_aid_application.summary_state
when :expired
"red"
when :submitted
"green"
else
"blue"
end
end
end
16 changes: 16 additions & 0 deletions app/models/legal_aid_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,18 @@ def merits_complete!
end

def summary_state
return :expired if expired?
return :submitted if merits_submitted_at

:in_progress
end

def expired?
[
expired_by_2023_surname_at_birth_issue?,
].any?
end

def policy_disregards?
policy_disregards&.any? ? true : false
end
Expand Down Expand Up @@ -561,6 +568,15 @@ def bank_statement_upload_path?

private

def expired_by_2023_surname_at_birth_issue?
created_at.year < 2024 &&
(provider_step.nil? || %i[end_of_applications
submitted_applications
use_ccms
use_ccms_employed
use_ccms_under16s].exclude?(provider_step.to_sym))
end

def client_not_given_consent_to_open_banking?
provider_received_citizen_consent == false
end
Expand Down
11 changes: 11 additions & 0 deletions app/services/flow/flows/provider_blocked.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Flow
module Flows
class ProviderBlocked < FlowSteps
STEPS = {
providers_blocked: {
path: ->(application) { urls.providers_legal_aid_application_block_path(application) },
},
}.freeze
end
end
end
1 change: 1 addition & 0 deletions app/services/flow/provider_flow_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ProviderFlowService < BaseFlowService
.deep_merge(Flows::ProviderCapital::STEPS)
.deep_merge(Flows::ProviderDependants::STEPS)
.deep_merge(Flows::ProviderMerits::STEPS)
.deep_merge(Flows::ProviderBlocked::STEPS)

use_steps(steps.freeze)
end
Expand Down
19 changes: 19 additions & 0 deletions app/views/providers/interrupt/blocks/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="interruption-panel">
<%= page_template(page_title: t(".title_html"), column_width: "full", template: :basic) do %>
<%= page_heading(size: "l") %>

<div class="maximize-text-width">
<p class="govuk-body"><%= t(".body_text") %></p>
<p class="govuk-body"><%= t(".options") %></p>
<ul class="govuk-list govuk-list--bullet">
<% t(".option_bullets").each do |bullet| %>
<li><%= bullet %></li>
<% end %>
</ul>
</div>

<div class='govuk-button-group'>
<%= govuk_button_link_to t(".applications"), providers_legal_aid_applications_path, class: "white-button", role: "button" %>
</div>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
end
end
row.with_cell(html_attributes: { class: "sortable-cell", "data-sort-value": t(application.summary_state, scope: %i[enums legal_aid_application summary_state]) }) do
govuk_tag(text: t(application.summary_state, scope: %i[enums legal_aid_application summary_state]), colour: application.summary_state == :submitted ? "green" : "blue")
govuk_tag(text: t(application.summary_state, scope: %i[enums legal_aid_application summary_state]), colour: tag_colour(application))
end
row.with_cell do
concat render partial: "shared/partials/modal_dialogue", locals: { application:, index: }
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/enums.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ en:
submission_paused: Submission paused
use_ccms: use_ccms
summary_state:
expired: Out of date
in_progress: In progress
submitted: Submitted
10 changes: 10 additions & 0 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1696,3 +1696,13 @@ en:
select_a_scope_limitation_error: Select a scope limitation
enter_valid_hearing_date_error: Enter a valid hearing date for %{scope_limitation}
enter_limitation_note_error: Enter a limitation note for %{scope_limitation}
interrupt:
blocks:
show:
title_html: You cannot submit this application
body_text: This is because it’s out of date. The application will be missing information because of service updates.
options: "You can (choose one of the following):"
option_bullets:
- make a new application for your client if you still need to submit one
- go back to your applications
applications: Make a new application
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@
patch :continue
patch :reset
end

scope module: :interrupt do
resource :block, only: %i[show], path: "out-of-date-application"
end
scope module: :proceeding_loop do
resources :delegated_functions, only: %i[show update]
resources :confirm_delegated_functions_date, only: %i[show update]
Expand Down
50 changes: 50 additions & 0 deletions spec/helpers/providers_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@
non_uk_home_addresses]
end

describe "#tag_colour" do
subject(:url_helper) { tag_colour(legal_aid_application) }

context "when the application has `expired`" do
let(:legal_aid_application) do
travel_to Date.parse("2023-12-25") do
create(:legal_aid_application, :with_multiple_proceedings_inc_section8, provider_step: "chances_of_success")
end
end

it { is_expected.to eql("red") }
end

context "when the application is submitted" do
let(:legal_aid_application) { create(:legal_aid_application, :with_merits_submitted_at) }

it { is_expected.to eql("green") }
end

context "when the application is not submitted" do
it { is_expected.to eql("blue") }
end
end

describe "#url_for_application" do
subject(:url_helper) { url_for_application(legal_aid_application) }

Expand Down Expand Up @@ -112,5 +136,31 @@
expect(url_for_application(legal_aid_application)).to eq("/providers/applications/#{legal_aid_application.id}/means/remove_dependants/#{dependant.id}?locale=en")
end
end

context "when the application predates the 2023 surname at birth issue" do
let(:legal_aid_application) do
travel_to Date.parse("2023-12-25") do
create(:legal_aid_application, :with_multiple_proceedings_inc_section8, provider_step:)
end
end

context "and the provider step is not in the expired_by_2023_surname_at_birth_issue expiry exclusion list" do
let(:provider_step) { "chances_of_success" }

it "routes to the block page" do
application_id = legal_aid_application.id
expect(url_for_application(legal_aid_application)).to eq("/providers/applications/#{application_id}/out-of-date-application?locale=en")
end
end

context "and the provider step is in the expired_by_2023_surname_at_birth_issue expiry exclusion list" do
let(:provider_step) { "submitted_applications" }

it "routes to the submitted application page" do
application_id = legal_aid_application.id
expect(url_for_application(legal_aid_application)).to eq("/providers/applications/#{application_id}/submitted_application?locale=en")
end
end
end
end
end
32 changes: 32 additions & 0 deletions spec/requests/providers/interrupt/blocks_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "rails_helper"

RSpec.describe Providers::Interrupt::BlocksController do
let(:legal_aid_application) { create(:legal_aid_application) }
let(:provider) { legal_aid_application.provider }

describe "GET /providers/applications/:id/blocked" do
subject(:get_request) { get providers_legal_aid_application_block_path(legal_aid_application) }

context "when the provider is not authenticated" do
before { get_request }

it_behaves_like "a provider not authenticated"
end

context "when the provider is authenticated" do
before do
login_as provider
get_request
end

it "returns http success" do
expect(response).to have_http_status(:ok)
end

it "shows text to use CCMS" do
get_request
expect(response.body).to include("You cannot submit this application")
end
end
end
end

0 comments on commit 338fddc

Please sign in to comment.