Skip to content

Commit

Permalink
AP-5474: Add start date for MTR-A feature flag
Browse files Browse the repository at this point in the history
This adds the following start date to each environment:
    UAT: 6 November 2024, as the date has passed, it will be enabled immediately the switch is enabled
    Staging: 12 November 2024, allows testing before the meeting on the 13th
    Production: 20 Novmeber 2024, actual release date

The Setting model is updated to check for the radio button being set to true and
 the current date being equal to, or greater than, the start date
  • Loading branch information
colinbruce committed Nov 7, 2024
1 parent 56d6c99 commit eea6265
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.special_childrens_act?
end

def self.means_test_review_a?
setting.means_test_review_a
setting.means_test_review_a && Time.zone.today >= Rails.configuration.x.mtr_a_start_date
end

def self.public_law_family?
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
:value,
:label,
inline: true,
hint: { text: t(".hints.means_test_review_a") },
hint: { text: t(".hints.means_test_review_a", date: Rails.configuration.x.mtr_a_start_date.to_fs) },
legend: { text: t(".labels.means_test_review_a") },
) %>

Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class Application < Rails::Application

config.x.maintenance_mode = ENV.fetch("MAINTENANCE_MODE", nil)&.downcase&.eql?("true")

# TODO: Remove with Setting.means_test_review_a feature flag #
config.x.mtr_a_start_date = Date.parse(ENV.fetch("MTR_A_START_DATE", "2024-11-20"))

# automatically include locale in the query string when generating urls with url_helpers
Rails.application.routes.default_url_options[:locale] = I18n.locale
config.i18n.default_locale = :en
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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
means_test_review_a: Select Yes to enable the Means Test Review (MTR) A feature after %{date}
public_law_family: Select Yes to enable Public Law Family feature

update:
Expand Down
2 changes: 2 additions & 0 deletions helm_deploy/apply-for-legal-aid/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ env:
secretKeyRef:
name: {{ template "apply-for-legal-aid.fullname" . }}
key: policyDisregardsStartDate
- name: MTR_A_START_DATE
value: {{ .Values.mtr_a_start_date | quote }}
- name: LEGAL_FRAMEWORK_API_HOST
valueFrom:
secretKeyRef:
Expand Down
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.
31 changes: 31 additions & 0 deletions spec/models/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,36 @@
expect(described_class.means_test_review_a?).to be false
expect(described_class.public_law_family?).to be false
end

describe ".means_test_review_a?" do
subject { described_class.means_test_review_a? }

context "when the flag is true and a date has been set in the future" do
before do
described_class.setting.update!(means_test_review_a: true)
allow(Rails.configuration.x).to receive(:mtr_a_start_date).and_return(Date.tomorrow)
end

it { is_expected.to be false }
end

context "when the flag is true and a date has been set in the past" do
before do
described_class.setting.update!(means_test_review_a: true)
allow(Rails.configuration.x).to receive(:mtr_a_start_date).and_return(Date.yesterday)
end

it { is_expected.to be true }
end

context "when the flag is false and a date has been set in the past" do
before do
described_class.setting.update!(means_test_review_a: false)
allow(Rails.configuration.x).to receive(:mtr_a_start_date).and_return(Date.yesterday)
end

it { is_expected.to be false }
end
end
end
end

0 comments on commit eea6265

Please sign in to comment.