Skip to content

Commit

Permalink
Update contract start date rules; amendments following review (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddieleeper committed Dec 20, 2023
1 parent fd17850 commit 1e2be83
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ available environments.
Run the following command `make <environment> edit-app-secrets`

#### Contract Start Date
The environment variable `CONTRACT_START_MONTHS_LIMIT` can be set to `5` to override
The custom configuration entry `config.x.form_eligibility.contract_start_months_limit` can be set to `5` to override
the default of six months prior to the current service start date.
`AppSettings.current.service_start_date`.
This can be set to either `5` or `6` anything else will default to `6`.
This should be set to either `5` or `6` anything else will default to `6`.

### SSH access

Expand Down
9 changes: 2 additions & 7 deletions app/models/form/eligibility_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,11 @@ def contract_start_date_eligible?(start_date)

# default to 6 and only allow 5 or 6. anything else results in 6.
def months_limit
limit = ENV.fetch("CONTRACT_START_MONTHS_LIMIT", 6).to_i
limit = Rails.configuration.x.form_eligibility.contract_start_months_limit.to_i
[5, 6].include?(limit) ? limit : 6
end

def months_limit_in_words
case months_limit
when 5
"five"
else
"six"
end
months_limit == 5 ? "five" : "six"
end
end
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ class Application < Rails::Application

config.x.govuk_notify.generic_email_template_id = ENV.fetch("GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID")
config.x.events.filtered_attributes = YAML.load_file(Rails.root.join("config/events/filtered_attributes.yml"))
config.x.form_eligibility.contract_start_months_limit = 6
end
end
4 changes: 2 additions & 2 deletions spec/models/form/eligibility_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
service_end_date: 1.month.from_now.end_of_month,
)
travel_to Time.zone.local(2024, 5, 31)
ENV["CONTRACT_START_MONTHS_LIMIT"] = "5"
Rails.configuration.x.form_eligibility.contract_start_months_limit = 5
end

after do
ENV.delete("CONTRACT_START_MONTHS_LIMIT")
Rails.configuration.x.form_eligibility.contract_start_months_limit = 6
end

let(:form) { build(:form, :eligible) }
Expand Down

0 comments on commit 1e2be83

Please sign in to comment.