Skip to content

Commit

Permalink
Merge pull request #6358 from ministryofjustice/ap-4788-add-home-addr…
Browse files Browse the repository at this point in the history
…ess-feature-flag

AP-4788: Add home address feature flag
  • Loading branch information
skdejong authored Feb 15, 2024
2 parents 2270678 + 30869b7 commit e84dab0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 3 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 @@ -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
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 @@ -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,
Expand All @@ -17,6 +18,7 @@ class SettingForm < BaseForm
:partner_means_assessment,
:linked_applications,
:collect_hmrc_data,
:home_address,
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 @@ -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
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 @@ -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 %>
2 changes: 2 additions & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240214160228_add_home_address_to_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddHomeAddressToSettings < ActiveRecord::Migration[7.1]
def change
add_column :settings, :home_address, :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: 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"
Expand Down Expand Up @@ -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|
Expand Down
4 changes: 4 additions & 0 deletions spec/models/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,6 +31,7 @@
partner_means_assessment: true,
linked_applications: true,
collect_hmrc_data: true,
home_address: false,
)
end

Expand All @@ -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
Expand All @@ -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
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 @@ -43,6 +43,7 @@
partner_means_assessment: "true",
linked_applications: "true",
collect_hmrc_data: "true",
home_address: "true",
},
}
end
Expand All @@ -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
Expand Down

0 comments on commit e84dab0

Please sign in to comment.