Skip to content

Commit

Permalink
MAP-1485 - Add PER/YRA id to move/profile feeds (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thource authored Aug 12, 2024
1 parent feb7ac2 commit d50d48c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/models/move.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ def for_feed
feed_attributes.merge!(to_location.for_feed(prefix: :to)) if to_location
feed_attributes.merge!(supplier.for_feed) if supplier

feed_attributes['person_escort_record_id'] = person_escort_record_id if person_escort_record_id.present?
feed_attributes['youth_risk_assessment_id'] = youth_risk_assessment_id if youth_risk_assessment_id.present?

feed_attributes
end

Expand Down
7 changes: 6 additions & 1 deletion app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def merge_assessment_answers!(new_assessment_answers, category)
end

def for_feed
attributes.slice(*FEED_ATTRIBUTES)
feed_attributes = attributes.slice(*FEED_ATTRIBUTES)

feed_attributes['person_escort_record_id'] = person_escort_record_id if person_escort_record_id.present?
feed_attributes['youth_risk_assessment_id'] = youth_risk_assessment_id if youth_risk_assessment_id.present?

feed_attributes
end

private
Expand Down
3 changes: 2 additions & 1 deletion spec/models/move_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@
end

describe '#for_feed' do
subject(:move) { create(:move) }
subject(:move) { create(:move, :with_person_escort_record) }

let(:expected_json) do
{
Expand Down Expand Up @@ -706,6 +706,7 @@
'to_location_type' => 'court',
'updated_at' => be_a(Time),
'supplier' => move.supplier.key,
'person_escort_record_id' => move.person_escort_record_id,
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
end

describe '#for_feed' do
subject(:profile) { create(:profile) }
subject(:profile) { create(:profile, :with_person_escort_record) }

let(:expected_json) do
{
Expand All @@ -189,6 +189,7 @@
'created_at' => be_a(Time),
'updated_at' => be_a(Time),
'assessment_answers' => [],
'person_escort_record_id' => profile.person_escort_record_id,
}
end

Expand Down

0 comments on commit d50d48c

Please sign in to comment.