-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create create_default_standard_court_orders_service.rb
- Loading branch information
1 parent
d0c1eab
commit cf56815
Showing
5 changed files
with
57 additions
and
49 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
37 changes: 37 additions & 0 deletions
37
app/services/deployment/create_default_standard_court_orders_service.rb
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,37 @@ | ||
module Deployment | ||
class CreateDefaultStandardCourtOrdersService | ||
DEFAULT_STANDARD_COURT_ORDERS = [ | ||
"Birth certificate for the Respondent’s", | ||
"Domestic Violence Education/Group", | ||
"Educational monitoring for the Respondent", | ||
"Educational or Vocational referrals", | ||
"Family therapy", | ||
"Housing support for the [parent]", | ||
"Independent living skills classes or workshops", | ||
"Individual therapy for the [parent]", | ||
"Individual therapy for the Respondent", | ||
"Learners’ permit for the Respondent, drivers’ education and driving hours when needed", | ||
"No contact with (mother, father, other guardian)", | ||
"Parenting Classes (mother, father, other guardian)", | ||
"Psychiatric Evaluation and follow all recommendations (child, mother, father, other guardian)", | ||
"Substance abuse assessment for the [parent]", | ||
"Substance Abuse Evaluation and follow all recommendations (child, mother, father, other guardian)", | ||
"Substance Abuse Treatment (child, mother, father, other guardian)", | ||
"Supervised visits", | ||
"Supervised visits at DSS", | ||
"Therapy (child, mother, father, other guardian)", | ||
"Tutor for the Respondent", | ||
"Urinalysis (child, mother, father, other guardian)", | ||
"Virtual Visits", | ||
"Visitation assistance for the Respondent to see [family]" | ||
].freeze | ||
|
||
def create_defaults | ||
CasaOrg.all.each do |casa_org| | ||
DEFAULT_STANDARD_COURT_ORDERS.each do |order| | ||
StandardCourtOrder.create(value: order, casa_org: casa_org) | ||
end | ||
end | ||
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
19 changes: 19 additions & 0 deletions
19
spec/services/deployment/create_default_standard_court_orders_service_spec.rb
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,19 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Deployment::CreateDefaultStandardCourtOrdersService do | ||
describe "#create_defaults" do | ||
let!(:casa_org_1) { create(:casa_org) } | ||
let!(:casa_org_2) { create(:casa_org) } | ||
|
||
it 'creates StandardCourtOrders from DEFAULT_STANDARD_COURT_ORDERS for each org' do | ||
stub_const("Deployment::CreateDefaultStandardCourtOrdersService::DEFAULT_STANDARD_COURT_ORDERS", | ||
["Default 1", "Default 2"]) | ||
|
||
described_class.new.create_defaults | ||
|
||
expect(StandardCourtOrder.count).to eq(4) | ||
expect(casa_org_1.standard_court_orders.map(&:value)).to eq(["Default 1", "Default 2"]) | ||
expect(casa_org_2.standard_court_orders.map(&:value)).to eq(["Default 1", "Default 2"]) | ||
end | ||
end | ||
end |