From 30869b7c156ea5c94978fc9c9ec17a6f82ffe27d Mon Sep 17 00:00:00 2001 From: skdejong <StephanieKdeJong@gmail.com> Date: Wed, 14 Feb 2024 17:52:04 +0000 Subject: [PATCH] ap-4788-add-home-address-feature-flag --- app/controllers/admin/settings_controller.rb | 3 ++- app/forms/settings/setting_form.rb | 4 +++- app/models/setting.rb | 4 ++++ app/views/admin/settings/show.html.erb | 10 ++++++++++ config/locales/en/admin.yml | 2 ++ .../20240214160228_add_home_address_to_settings.rb | 5 +++++ db/schema.rb | 3 ++- spec/models/setting_spec.rb | 4 ++++ spec/requests/admin/settings_controller_spec.rb | 2 ++ 9 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20240214160228_add_home_address_to_settings.rb diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index a15603cfbe..4181c53417 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -24,7 +24,8 @@ def form_params :enable_ccms_submission, :partner_means_assessment, :linked_applications, - :collect_hmrc_data) + :collect_hmrc_data, + :home_address) end def setting diff --git a/app/forms/settings/setting_form.rb b/app/forms/settings/setting_form.rb index ba9f9c1e67..5b0f1718bd 100644 --- a/app/forms/settings/setting_form.rb +++ b/app/forms/settings/setting_form.rb @@ -8,7 +8,8 @@ class SettingForm < BaseForm :enable_ccms_submission, :partner_means_assessment, :linked_applications, - :collect_hmrc_data + :collect_hmrc_data, + :home_address validates :mock_true_layer_data, :manually_review_all_cases, @@ -17,6 +18,7 @@ class SettingForm < BaseForm :partner_means_assessment, :linked_applications, :collect_hmrc_data, + :home_address, presence: true end end diff --git a/app/models/setting.rb b/app/models/setting.rb index 4a0c330e4c..a59d624d5b 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -35,6 +35,10 @@ def self.collect_hmrc_data? setting.collect_hmrc_data end + def self.home_address? + setting.home_address + end + def self.setting Setting.first || Setting.create! end diff --git a/app/views/admin/settings/show.html.erb b/app/views/admin/settings/show.html.erb index c8a4c7190a..c990588cbb 100644 --- a/app/views/admin/settings/show.html.erb +++ b/app/views/admin/settings/show.html.erb @@ -76,6 +76,16 @@ legend: { text: t(".labels.collect_hmrc_data") }, ) %> + <%= form.govuk_collection_radio_buttons( + :home_address, + yes_no_options, + :value, + :label, + inline: true, + hint: { text: t(".hints.home_address") }, + legend: { text: t(".labels.home_address") }, + ) %> + <%= form.govuk_submit(t("generic.submit")) %> <% end %> <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 7daa1bfc94..7d92485cde 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -75,6 +75,7 @@ en: partner_means_assessment: Enable Partner Means Assessment linked_applications: Enable linked applications collect_hmrc_data: Collect HMRC data + home_address: Enable home address hints: mock_true_layer_data: Select Yes and TrueLayer data will be replaced by mock data from %{bank_transaction_filename} manually_review_all_cases: | @@ -86,6 +87,7 @@ en: 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 + home_address: Select Yes to enable the home address feature for solicitors update: notice: Settings have been updated submitted_applications_reports: diff --git a/db/migrate/20240214160228_add_home_address_to_settings.rb b/db/migrate/20240214160228_add_home_address_to_settings.rb new file mode 100644 index 0000000000..da361b7979 --- /dev/null +++ b/db/migrate/20240214160228_add_home_address_to_settings.rb @@ -0,0 +1,5 @@ +class AddHomeAddressToSettings < ActiveRecord::Migration[7.1] + def change + add_column :settings, :home_address, :boolean, null: false, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index b6cda45343..64a90db51e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_02_06_145546) do +ActiveRecord::Schema[7.1].define(version: 2024_02_14_160228) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -950,6 +950,7 @@ t.datetime "cfe_compare_run_at" t.boolean "linked_applications", default: false, null: false t.boolean "collect_hmrc_data", default: false, null: false + t.boolean "home_address", default: false, null: false end create_table "specific_issues", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 6dced23180..fa935fc265 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -15,6 +15,7 @@ expect(rec.partner_means_assessment?).to be false expect(rec.linked_applications?).to be false expect(rec.collect_hmrc_data?).to be false + expect(rec.home_address?).to be false end end @@ -30,6 +31,7 @@ partner_means_assessment: true, linked_applications: true, collect_hmrc_data: true, + home_address: false, ) end @@ -44,6 +46,7 @@ expect(rec.partner_means_assessment?).to be true expect(rec.linked_applications?).to be true expect(rec.collect_hmrc_data?).to be true + expect(rec.home_address?).to be false end end end @@ -61,6 +64,7 @@ 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 + expect(described_class.home_address?).to be false end end end diff --git a/spec/requests/admin/settings_controller_spec.rb b/spec/requests/admin/settings_controller_spec.rb index 982f3b98cf..a5a468af74 100644 --- a/spec/requests/admin/settings_controller_spec.rb +++ b/spec/requests/admin/settings_controller_spec.rb @@ -43,6 +43,7 @@ partner_means_assessment: "true", linked_applications: "true", collect_hmrc_data: "true", + home_address: "true", }, } end @@ -59,6 +60,7 @@ expect(setting.partner_means_assessment?).to be(true) expect(setting.linked_applications?).to be(true) expect(setting.collect_hmrc_data?).to be(true) + expect(setting.home_address?).to be(true) end it "create settings if they do not exist" do