Skip to content

Commit

Permalink
Merge pull request #6273 from ministryofjustice/ap-4758-enable-HMRC-s…
Browse files Browse the repository at this point in the history
…ervice-toggling

AP-4758: Enable HMRC service environment toggling
  • Loading branch information
agoldstone93 authored Jan 29, 2024
2 parents 44db30e + c0b939a commit e79b5e5
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 54 deletions.
3 changes: 2 additions & 1 deletion app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def form_params
:allow_welsh_translation,
:enable_ccms_submission,
:partner_means_assessment,
:linked_applications)
:linked_applications,
:collect_hmrc_data)
end

def setting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def correct_dwp_result?
end

def hmrc_call_enabled?
Rails.configuration.x.collect_hmrc_data
Setting.collect_hmrc_data?
end

def make_hmrc_call?
Expand Down
4 changes: 3 additions & 1 deletion app/forms/settings/setting_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ class SettingForm < BaseForm
:allow_welsh_translation,
:enable_ccms_submission,
:partner_means_assessment,
:linked_applications
:linked_applications,
:collect_hmrc_data

validates :mock_true_layer_data,
:manually_review_all_cases,
:allow_welsh_translation,
:enable_ccms_submission,
:partner_means_assessment,
:linked_applications,
:collect_hmrc_data,
presence: true
end
end
4 changes: 4 additions & 0 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def self.linked_applications?
setting.linked_applications
end

def self.collect_hmrc_data?
setting.collect_hmrc_data
end

def self.setting
Setting.first || Setting.create!
end
Expand Down
10 changes: 10 additions & 0 deletions app/views/admin/settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
legend: { text: t(".labels.linked_applications") },
) %>

<%= form.govuk_collection_radio_buttons(
:collect_hmrc_data,
yes_no_options,
:value,
:label,
inline: true,
hint: { text: t(".hints.collect_hmrc_data") },
legend: { text: t(".labels.collect_hmrc_data") },
) %>

<%= form.govuk_submit(t("generic.submit")) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<% suffix = if !@legal_aid_application.applicant.national_insurance_number?
<% suffix = if !Setting.collect_hmrc_data?
:hmrc_data_collection_off
elsif !@legal_aid_application.applicant.national_insurance_number?
:no_nino
elsif @legal_aid_application.applicant.has_multiple_employments?
:multiple_employments
Expand Down
3 changes: 0 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,4 @@

config.active_storage.service = :local
config.x.application.host_url = "http://#{config.x.application.host}"

# Switch to determine whether or not o collect HMRC data
config.x.collect_hmrc_data = true
end
3 changes: 0 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,4 @@

# set the id of the Digest Export spreadsheet to use in this environment
config.x.digest_export.spreadsheet_id = "1dXnEdiqqP_fOeWzDsbXY83lwwK8pvf8j4jsUqaGnGMs"

# Switch to determine whether or not o collect HMRC data
config.x.collect_hmrc_data = true
end
3 changes: 0 additions & 3 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@
# set the id of the Digest Export spreadsheet to use in this environment
config.x.digest_export.spreadsheet_id = "1dXnEdiqqP_fOeWzDsbXY83lwwK8pvf8j4jsUqaGnGMs"

# Switch to determine whether or not o collect HMRC data
config.x.collect_hmrc_data = true

# This needs adding due to a rails 7.1.1 bug(?!) related to Unsafe threading and AR connection pool issues
# see https://github.com/rails/rails/issues/46797 for a good description
config.active_job.queue_adapter = :test
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ en:
enable_evidence_upload: Enable the new evidence upload feature
partner_means_assessment: Enable Partner Means Assessment
linked_applications: Enable linked applications
collect_hmrc_data: Collect HMRC data
hints:
mock_true_layer_data: Select Yes and TrueLayer data will be replaced by mock data from %{bank_transaction_filename}
manually_review_all_cases: |
Expand All @@ -84,6 +85,7 @@ en:
enable_evidence_upload: Select Yes to enable the new evidence upload feature for solicitors
partner_means_assessment: Select Yes to allow Providers to complete the Partner Means Assessment
linked_applications: Select Yes to enable the linked applications feature for solicitors
collect_hmrc_data: Select Yes to enable calls to HMRC for employment data
update:
notice: Settings have been updated
submitted_applications_reports:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,11 @@ en:
page_heading_no_data: HMRC has no record of %{individual}'s employment in the last 3 months
page_heading_multiple_employments: HMRC found a record of %{individual}'s employment
page_heading_no_nino: We could not check %{individual}'s employment record with HMRC
page_heading_hmrc_data_collection_off: Enter details of your client's employment in the last 3 months
info_no_data: You told us %{individual} is employed but HMRC could not confirm this.
info_multiple_employments: HMRC says %{individual} had more than one job in the last 3 months.
info_no_nino: Because you did not give us %{individual}'s National Insurance number, we could not check this with HMRC.
info_hmrc_data_collection_off: We cannot currently check employment records automatically with HMRC.
enter_details_client: "Enter details of your client's employment in the last 3 months, including:"
enter_details_partner: "You must give the partner's employment details for the last 3 months, including:"
details:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCollectHMRCDataToSettings < ActiveRecord::Migration[7.1]
def change
add_column :settings, :collect_hmrc_data, :boolean, null: false, default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_12_05_180352) do
ActiveRecord::Schema[7.1].define(version: 2024_01_24_161717) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -947,6 +947,7 @@
t.boolean "partner_means_assessment", default: false, null: false
t.datetime "cfe_compare_run_at"
t.boolean "linked_applications", default: false, null: false
t.boolean "collect_hmrc_data", default: false, null: false
end

create_table "specific_issues", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
Expand Down
1 change: 1 addition & 0 deletions features/providers/check_multiple_employment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Check multiple employment
@javascript @vcr @hmrc_use_dev_mock
Scenario: I am able to complete an application for an employed applicant with multiple employers
Given I am logged in as a provider
And the feature flag for collect_hmrc_data is enabled
And csrf is enabled
And an applicant named Ida Paisley has completed his true layer interaction

Expand Down
1 change: 1 addition & 0 deletions features/providers/check_pending_employment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Check pending employment
@javascript @vcr @hmrc_use_dev_mock
Scenario: I am able to complete an application for an employed applicant with pending HMRC request
Given I am logged in as a provider
And the feature flag for collect_hmrc_data is enabled
And csrf is enabled
And an applicant named John Pending has completed his true layer interaction

Expand Down
2 changes: 2 additions & 0 deletions features/providers/employed_journey.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Scenario: Completing the means journey for an employed applicant with HMRC data
@javascript
Scenario: Completing the means journey for an employed applicant with no HMRC data
Given I start the means review journey with no employment income from HMRC
And the feature flag for collect_hmrc_data is enabled
Then I should be on the 'client_completed_means' page showing 'Your client has shared their financial information'
When I click 'Continue'
Then I should be on the 'full_employment_details' page showing "HMRC has no record of your client's employment in the last 3 months"
Expand Down Expand Up @@ -63,6 +64,7 @@ Scenario: Completing the means journey for an employed applicant with no HMRC da
@javascript
Scenario: Completing the means journey for an employed applicant with multiple jobs
Given I start the means review journey with employment income for multiple jobs from HMRC
And the feature flag for collect_hmrc_data is enabled
Then I should be on the 'client_completed_means' page showing 'Your client has shared their financial information'
When I click 'Continue'
Then I should be on the 'full_employment_details' page showing "HMRC says your client had more than one job in the last 3 months."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Feature: partner_means_assessment means check
@javascript @vcr @hmrc_use_dev_mock
Scenario: I am able to navigate to partners means check when doing open banking upload
Given the feature flag for partner_means_assessment is enabled
And the feature flag for collect_hmrc_data is enabled
And I am logged in as a provider
And csrf is enabled
And an applicant named Ida Paisley with a partner has completed their true layer interactions
Expand Down
5 changes: 5 additions & 0 deletions helm_deploy/apply-for-legal-aid/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,9 @@ env:
secretKeyRef:
name: {{ template "apply-for-legal-aid.fullname" . }}
key: slackAlertWebhook
- name: COLLECT_HMRC_DATA
valueFrom:
secretKeyRef:
name: {{ template "apply-for-legal-aid.fullname" . }}
key: collectHmrcData
{{- end }}
1 change: 1 addition & 0 deletions helm_deploy/apply-for-legal-aid/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ data:
encryptionKeyDerivationSalt: {{ .Values.active_record_encryption.key_derivation_salt | b64enc | quote }}
maintenanceMode: {{ .Values.maintenance_mode.enabled | b64enc | quote }}
slackAlertWebhook: {{ .Values.slack_webhooks.alert | b64enc | quote }}
collectHmrcData: {{ .Values.collect_hmrc_data.enabled | b64enc | quote }}
Binary file modified helm_deploy/apply-for-legal-aid/values-production.yaml
Binary file not shown.
Binary file modified helm_deploy/apply-for-legal-aid/values-staging.yaml
Binary file not shown.
Binary file modified helm_deploy/apply-for-legal-aid/values-uat.yaml
Binary file not shown.
4 changes: 4 additions & 0 deletions spec/models/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
expect(rec.alert_via_sentry?).to be true
expect(rec.partner_means_assessment?).to be false
expect(rec.linked_applications?).to be false
expect(rec.collect_hmrc_data?).to be false
end
end

Expand All @@ -28,6 +29,7 @@
alert_via_sentry: true,
partner_means_assessment: true,
linked_applications: true,
collect_hmrc_data: true,
)
end

Expand All @@ -41,6 +43,7 @@
expect(rec.alert_via_sentry?).to be true
expect(rec.partner_means_assessment?).to be true
expect(rec.linked_applications?).to be true
expect(rec.collect_hmrc_data?).to be true
end
end
end
Expand All @@ -57,6 +60,7 @@
expect(described_class.alert_via_sentry?).to be true
expect(described_class.partner_means_assessment?).to be false
expect(described_class.linked_applications?).to be false
expect(described_class.collect_hmrc_data?).to be false
end
end
end
2 changes: 2 additions & 0 deletions spec/requests/admin/settings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
enable_ccms_submission: "true",
partner_means_assessment: "true",
linked_applications: "true",
collect_hmrc_data: "true",
},
}
end
Expand All @@ -57,6 +58,7 @@
expect(setting.allow_welsh_translation?).to be(true)
expect(setting.partner_means_assessment?).to be(true)
expect(setting.linked_applications?).to be(true)
expect(setting.collect_hmrc_data?).to be(true)
end

it "create settings if they do not exist" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
RSpec.describe Providers::ConfirmDWPNonPassportedApplicationsController do
let(:application) { create(:legal_aid_application, :with_proceedings, :at_checking_applicant_details, :with_applicant_and_address) }
let(:application_id) { application.id }
let(:enable_hmrc_collection) { true }

before { allow(Setting).to receive(:collect_hmrc_data?).and_return(enable_hmrc_collection) }

describe "GET /providers/applications/:legal_aid_application_id/confirm_dwp_non_passported_applications" do
subject(:get_request) { get "/providers/applications/#{application_id}/confirm_dwp_non_passported_applications" }
Expand Down Expand Up @@ -118,9 +121,20 @@
expect(application.reload.state_machine_proxy.type).to eq "NonPassportedStateMachine"
end

it "calls the HMRC::CreateResponsesService" do
patch_request
expect(HMRC::CreateResponsesService).to have_received(:call).once
context "and the hmrc toggle is true" do
it "calls the HMRC::CreateResponsesService" do
patch_request
expect(HMRC::CreateResponsesService).to have_received(:call).once
end
end

context "and the hmrc toggle is false" do
let(:enable_hmrc_collection) { false }

it "doesn't call the HMRC::CreateResponsesService" do
patch_request
expect(HMRC::CreateResponsesService).not_to have_received(:call)
end
end

it "successfully deletes any existing dwp override" do
Expand Down
Loading

0 comments on commit e79b5e5

Please sign in to comment.