Skip to content

Commit

Permalink
Create create_default_standard_court_orders_service.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmaboros committed Jul 15, 2024
1 parent d0c1eab commit cf56815
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 49 deletions.
5 changes: 0 additions & 5 deletions app/models/case_court_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ class CaseCourtOrder < ApplicationRecord

enum implementation_status: IMPLEMENTATION_STATUSES

# TODO: assess what we're doing with this method
def self.court_order_options
STANDARD_COURT_ORDERS.map { |o| [o, o] }
end

def implementation_status_symbol
case implementation_status
when "implemented"
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,11 @@ namespace :after_party do
puts "Running deploy task 'create_default_standard_court_orders'"

# Put your task implementation HERE.
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

CasaOrg.all.each do |casa_org|
create_default_standard_court_orders(casa_org, default_standard_court_orders)
end
Deployment::CreateDefaultStandardCourtOrdersService.new.create_defaults

# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end

# TODO: tests!?!
def create_default_standard_court_orders(casa_org, default_standard_court_orders)
default_standard_court_orders.each do |order|
StandardCourtOrder.create(value: order, casa_org: casa_org)
end
end
end
8 changes: 0 additions & 8 deletions spec/models/case_court_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,4 @@
it { is_expected.to belong_to(:casa_case) }

it { is_expected.to validate_presence_of(:text) }

describe ".court_order_options" do
it "returns standard court order options" do
expect(described_class.court_order_options.count).to eq(23)
expect(described_class.court_order_options).to be_an(Array)
expect(described_class.court_order_options).to all be_an(Array)
end
end
end
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

0 comments on commit cf56815

Please sign in to comment.