Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAP-1809 PerMedical attributes can be optional #2394

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/models/generic_event/medical.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def self.inherited(child)
child.include LocationFeed
child.include LocationValidations

child.validates :advised_at, presence: true, iso_date_time: true
child.validates :advised_by, presence: true
child.validates :advised_at, allow_nil: true, iso_date_time: true
child.validates :treated_at, allow_nil: true, iso_date_time: true

super
Expand Down
9 changes: 4 additions & 5 deletions spec/support/an_event_about_a_medical.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
it_behaves_like 'an event with a supplier personnel number'
it_behaves_like 'an event with a location in the feed', :location_id

it { is_expected.to validate_presence_of(:advised_at) }
it { is_expected.to validate_presence_of(:advised_by) }

it { is_expected.to validate_inclusion_of(:eventable_type).in_array(%w[PersonEscortRecord]) }

it { is_expected.to validate_presence_of(:supplier_personnel_number) }
Expand All @@ -28,10 +25,12 @@
it { is_expected.not_to be_valid }
end

context 'when the treated_at and treated_by are nil' do
context 'when the advised_at, advised_by, treated_at and treated_by are nil' do
before do
generic_event.treated_by = nil
generic_event.advised_at = nil
generic_event.advised_by = nil
generic_event.treated_at = nil
generic_event.treated_by = nil
end

it { is_expected.to be_valid }
Expand Down
Loading