Skip to content

Commit

Permalink
AP-5220: Change "My clients UK home address" to "A UK office address"
Browse files Browse the repository at this point in the history
Use change links to change where to send client's correspondence.
Move delete methods to provider_base_controller as they're reused.
Delete correspondence_address as previous address is no longer relevant.
  • Loading branch information
agoldstone93 committed Aug 27, 2024
1 parent c746cd6 commit 1a95d1c
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def show
def update
@form = Addresses::ChoiceForm.new(form_params)

delete_client_no_fixed_residence if form_params[:correspondence_address_choice].eql?("home")
delete_no_fixed_residence if form_params[:correspondence_address_choice].eql?("home")

if form_params[:correspondence_address_choice].eql?("office") && !applicant.correspondence_address_choice.eql?("office")
delete_correspondence_address
end

render :show unless save_continue_or_draft(@form)
end
Expand All @@ -21,7 +25,7 @@ def applicant
legal_aid_application.applicant
end

def delete_client_no_fixed_residence
def delete_no_fixed_residence
applicant.no_fixed_residence = nil
applicant.save!
end
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/providers/home_address/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ def update

private

def delete_home_address
applicant.home_address = nil
applicant.save!
end

def applicant
legal_aid_application.applicant
end
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/providers/provider_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ class ProviderBaseController < FlowBaseController

private

def delete_home_address
applicant.home_address = nil
applicant.save!
end

def delete_correspondence_address
applicant.address = nil
applicant.save!
end

def display_employment_income?
@legal_aid_application.cfe_result.version >= 4 &&
@legal_aid_application.cfe_result.jobs?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Addresses
path: ->(application) { Steps.urls.providers_legal_aid_application_correspondence_address_care_of_path(application) },
forward: :home_address_statuses,
check_answers: :check_provider_answers,
carry_on_sub_flow: lambda do |application|
application.applicant.no_fixed_residence.nil? && !application.applicant.correspondence_address_choice.eql?("home")
end,
)
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 45 additions & 1 deletion features/providers/check_provider_answers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,50 @@ Feature: Checking client details answers backwards and forwards
| Care of recipient |
| Client has a home address? |

@javascript @vcr
Scenario: I am able to change from "My client's UK home address" to "A UK office address"
Given I complete the passported journey as far as check your answers for client details
And the "Client details" check your answers section should contain:
| question | answer |
| Home address | Transport For London\n98 Petty France\nLondon\nSW1H 9EA |
When I click Check Your Answers Change link for "correspondence address choice"
Then I should be on a page with title "Where should we send your client's correspondence?"

When I choose "A UK office address"
And I click "Save and continue"
Then I should be on a page with title "Enter your client's correspondence address"

When I enter address line one 'British Transport Police'
And I enter address line two '98 Petty France'
And I enter city 'London'
And I enter a postcode 'SW1H 9EA'
And I click 'Save and continue'
Then I should be on a page with title "Do you want to add a 'care of' recipient for your client's mail?"

When I choose "Yes, a person"
And I enter First name "Brian"
And I enter Last name "Surname"
And I click "Save and continue"
Then I should be on a page with title "Does your client have a home address"

When I choose "Yes"
And I click "Save and continue"
Then I should be on a page with title "Find your client's home address"

When I click "Find address"
Then I should be on a page with title "Select your client's home address"

When I choose "Transport For London, 98 Petty France, London, SW1H 9EA"
And I click "Use this address"

Then I should be on a page with title "Check your answers"
And the "Client details" check your answers section should contain:
| question | answer |
| Correspondence address | British Transport Police\n98 Petty France\nLondon\nSW1H 9EA |
| Home address | Transport For London\n98 Petty France\nLondon\nSW1H 9EA |
| Care of recipient | Brian Surname |
| Client has a home address? | Yes |

@javascript
Scenario: I am able to return and remove the client's national insurance number
Given I complete the passported journey as far as check your answers for client details
Expand Down Expand Up @@ -263,7 +307,7 @@ Feature: Checking client details answers backwards and forwards

@javascript @vcr
Scenario: I want to change address manually from the check your answers page
Given I complete the journey as far as check your answers
Given I complete the passported journey as far as check your answers and send correspondence to another uk residential address
And I click Check Your Answers Change link for 'Address'
Then I should be on a page showing "Find your client's correspondence address"
Then I enter a postcode 'XX1 1XX'
Expand Down

0 comments on commit 1a95d1c

Please sign in to comment.