Skip to content

Commit 39b3597

Browse files
authored
Merge pull request #5604 from nhsuk/revert-5595-revert-5594-default-consent-disease-types
Revert "Revert "Default `disease_types` from programme in `DraftConsent`""
2 parents eb4e22f + 65c152b commit 39b3597

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

app/models/draft_consent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def write_to!(consent, triage_form:)
327327
consent.parent = parent
328328
consent.submitted_at ||= Time.current
329329
consent.academic_year = academic_year if academic_year.present?
330-
consent.disease_types = disease_types
330+
consent.disease_types = disease_types.presence || programme.disease_types
331331

332332
if triage_allowed? && requires_triage?
333333
triage_form.add_patient_specific_direction =

spec/models/draft_consent_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@
114114
end
115115
end
116116
end
117+
118+
context "when disease_types is not present" do
119+
it "falls back to the disease types from the programme" do
120+
freeze_time do
121+
expect { write_to }.to change(consent, :disease_types).from(nil).to(
122+
Programme::DISEASE_TYPES[programme.type]
123+
)
124+
end
125+
end
126+
end
117127
end
118128

119129
describe "#reset_unused_attributes" do

0 commit comments

Comments
 (0)