Skip to content

Commit

Permalink
Merge pull request #7214 from ministryofjustice/ap-5313-create-mtr-a-…
Browse files Browse the repository at this point in the history
…feature-flag

AP-5313: create MTR A feature flag
  • Loading branch information
agoldstone93 authored Sep 24, 2024
2 parents fc3888c + 8114b67 commit d626868
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 7 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,
:linked_applications,
:collect_hmrc_data,
:special_childrens_act)
:special_childrens_act,
:means_test_review_a)
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,
:linked_applications,
:collect_hmrc_data,
:special_childrens_act
:special_childrens_act,
:means_test_review_a

validates :mock_true_layer_data,
:manually_review_all_cases,
Expand All @@ -17,6 +18,7 @@ class SettingForm < BaseForm
:linked_applications,
:collect_hmrc_data,
:special_childrens_act,
:means_test_review_a,
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.special_childrens_act?
setting.special_childrens_act
end

def self.means_test_review_a?
setting.means_test_review_a
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.special_childrens_act") },
) %>
<%= form.govuk_collection_radio_buttons(
:means_test_review_a,
yes_no_options,
:value,
:label,
inline: true,
hint: { text: t(".hints.means_test_review_a") },
legend: { text: t(".labels.means_test_review_a") },
) %>
<%= form.govuk_submit(t("generic.submit")) %>
<% end %>
<% end %>
3 changes: 3 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:
linked_applications: Enable linking and copying cases
collect_hmrc_data: Collect HMRC data
special_childrens_act: Enable Special Childrens Act
means_test_review_a: Enable Means Test Review (MTR) A
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,8 @@ en:
linked_applications: Select Yes to enable the linking and copying cases feature for solicitors
collect_hmrc_data: Select Yes to enable calls to HMRC for employment data
special_childrens_act: Select Yes to enable the special childrens act matter type
means_test_review_a: Select Yes to enable the Means Test Review (MTR) A feature

update:
notice: Settings have been updated
submitted_applications_reports:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMeansTestReviewAToSettings < ActiveRecord::Migration[7.1]
def change
add_column :settings, :means_test_review_a, :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_09_13_145848) do
ActiveRecord::Schema[7.1].define(version: 2024_09_23_104047) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -977,6 +977,7 @@
t.boolean "collect_hmrc_data", default: false, null: false
t.boolean "home_address", default: false, null: false
t.boolean "special_childrens_act", default: false, null: false
t.boolean "means_test_review_a", default: false, null: false
end

create_table "specific_issues", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
Expand Down
13 changes: 9 additions & 4 deletions spec/models/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
expect(rec.mock_true_layer_data?).to be false
expect(rec.manually_review_all_cases?).to be true
expect(rec.allow_welsh_translation?).to be false
expect(rec.enable_ccms_submission?).to be true
expect(rec.bank_transaction_filename).to eq "db/sample_data/bank_transactions.csv"
expect(rec.alert_via_sentry?).to be true
expect(rec.linked_applications?).to be false
expect(rec.collect_hmrc_data?).to be false
expect(rec.special_childrens_act?).to be false
expect(rec.means_test_review_a?).to be false
end
end

Expand All @@ -23,27 +25,29 @@
described_class.setting.update!(
mock_true_layer_data: true,
manually_review_all_cases: false,
allow_welsh_translation: false,
allow_welsh_translation: true,
enable_ccms_submission: false,
bank_transaction_filename: "my_special_file.csv",
alert_via_sentry: true,
alert_via_sentry: false,
linked_applications: true,
collect_hmrc_data: true,
special_childrens_act: true,
means_test_review_a: true,
)
end

it "returns the existing record" do
rec = described_class.setting
expect(rec.mock_true_layer_data?).to be true
expect(rec.manually_review_all_cases?).to be false
expect(rec.allow_welsh_translation?).to be false
expect(rec.allow_welsh_translation?).to be true
expect(rec.enable_ccms_submission?).to be false
expect(rec.bank_transaction_filename).to eq "my_special_file.csv"
expect(rec.alert_via_sentry?).to be true
expect(rec.alert_via_sentry?).to be false
expect(rec.linked_applications?).to be true
expect(rec.collect_hmrc_data?).to be true
expect(rec.special_childrens_act?).to be true
expect(rec.means_test_review_a?).to be true
end
end
end
Expand All @@ -61,6 +65,7 @@
expect(described_class.linked_applications?).to be false
expect(described_class.collect_hmrc_data?).to be false
expect(described_class.special_childrens_act?).to be false
expect(described_class.means_test_review_a?).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 @@ -44,6 +44,7 @@
collect_hmrc_data: "true",
home_address: "true",
special_childrens_act: "true",
means_test_review_a: "true",
},
}
end
Expand All @@ -60,6 +61,7 @@
expect(setting.linked_applications?).to be(true)
expect(setting.collect_hmrc_data?).to be(true)
expect(setting.special_childrens_act?).to be(true)
expect(setting.means_test_review_a?).to be(true)
end

it "create settings if they do not exist" do
Expand Down

0 comments on commit d626868

Please sign in to comment.