-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds case contact topics model - shoulda matcher validations feat: adds default topics - adds default topics in yml file - adds checks to only allow certain keys feat: adds tests for case contact methods - tests generation for casa orgs - tests creation of dupes feat: add contact topics seeding feat: tests for form controller - case_contact form_controller update step only updates correct values - case contact controller create step creates default topics from org on case contact feat: adds tests for casa admin Tests that when a admin creates a casa org the default contact topics are created.
- Loading branch information
1 parent
bb9e9e7
commit 50c304a
Showing
20 changed files
with
411 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class CaseContactTopic < ApplicationRecord | ||
CASA_DEFAULT_COURT_TOPICS = Rails.root.join("data", "default_contact_topics.yml") | ||
REQUIRED_ATTRS = %w[title details].freeze | ||
|
||
belongs_to :casa_org | ||
belongs_to :case_contact, optional: true | ||
|
||
validates :title, :details, presence: true | ||
|
||
class << self | ||
def generate_for_org!(casa_org) | ||
default_contact_topics.each do |topic| | ||
filtered_topic = topic.select { |k, _| REQUIRED_ATTRS.include?(k) } | ||
find_or_create_by!(casa_org:, **filtered_topic) | ||
end | ||
end | ||
|
||
private | ||
|
||
def default_contact_topics | ||
YAML.load_file(CASA_DEFAULT_COURT_TOPICS) | ||
end | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: case_contact_topics | ||
# | ||
# id :bigint not null, primary key | ||
# active :boolean default(FALSE) | ||
# answer :string | ||
# details :string | ||
# title :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# casa_org_id :bigint not null | ||
# case_contact_id :bigint | ||
# | ||
# Indexes | ||
# | ||
# index_case_contact_topics_on_casa_org_id (casa_org_id) | ||
# index_case_contact_topics_on_case_contact_id (case_contact_id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
- title: "Background information" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." | ||
- title: "Current situation" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." | ||
- title: "Education, vocation, or daycare" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." | ||
- title: "Health and mental health" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." | ||
- title: "Family and community connections" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." | ||
- title: "Child’s strengths" | ||
details: | ||
"a) When did the family first come into contact with the Department of Social Services or Department of Juvenile Justice – how many times? | ||
b) Tell the history of their involvement with the department and any facts about their life that could help determine the need for placement and/or services. | ||
c) Discuss the child’s history – behavior problems, educational history, medical history, psychological history (any hospitalizations, previous counseling, etc.) | ||
d) If child has been placed previously give a history of the child’s placements (placed with different parents, relatives, DSS, etc)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateCaseContactTopics < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :case_contact_topics do |t| | ||
t.string :title | ||
t.string :details | ||
t.string :answer | ||
t.boolean :active, default: false | ||
t.references :casa_org, null: false | ||
t.references :case_contact, null: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ContactTopicPopulator | ||
def self.populate | ||
CasaOrg.all.each do |casa_org| | ||
CaseContactTopic.generate_for_org!(casa_org) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FactoryBot.define do | ||
factory :case_contact_topic do | ||
title { Faker::Lorem.sentence } | ||
details { Faker::Lorem.paragraph } | ||
casa_org | ||
case_contact | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.