+ <% if !@casa_case.active%>
+ <%= render "inactive_case", casa_case: @casa_case%>
+ <% end %>
Case number: <%= @casa_case.case_number %>
diff --git a/app/views/volunteers/edit.html.erb b/app/views/volunteers/edit.html.erb
index e0818d13df..5d147960e9 100644
--- a/app/views/volunteers/edit.html.erb
+++ b/app/views/volunteers/edit.html.erb
@@ -82,14 +82,16 @@
<%= link_to assignment.casa_case.case_number, casa_case_path(assignment.casa_case) %> |
<%= assignment.casa_case.decorate.transition_aged_youth_icon %> |
- <% if @volunteer.active? %>
+ <% if @volunteer.active? && assignment.casa_case.active? %>
Volunteer is Active
+ <% elsif @volunteer.active? %>
+ Case was deactivated on: <%= assignment.casa_case.updated_at.strftime("%m-%d-%Y") %>
<% else %>
Deactivated
<% end %>
|
- <% if @volunteer.active? %>
+ <% if @volunteer.active? && assignment.casa_case.active? %>
<%- if Pundit.policy(current_user, @volunteer).unassign_case? %>
<%= button_to 'Unassign Case',
case_assignment_path(assignment, volunteer_id: @volunteer.id),
diff --git a/config/routes.rb b/config/routes.rb
index b76a1351a9..10e2937101 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,7 +20,12 @@
root to: "all_casa_admins/sessions#new", as: :unauthenticated_all_casa_root
end
- resources :casa_cases
+ resources :casa_cases do
+ member do
+ patch :deactivate
+ patch :reactivate
+ end
+ end
resources :casa_admins, except: %i[destroy] do
member do
diff --git a/db/migrate/20201021143642_add_active_column_to_casa_cases_table.rb b/db/migrate/20201021143642_add_active_column_to_casa_cases_table.rb
new file mode 100644
index 0000000000..9e577599f2
--- /dev/null
+++ b/db/migrate/20201021143642_add_active_column_to_casa_cases_table.rb
@@ -0,0 +1,5 @@
+class AddActiveColumnToCasaCasesTable < ActiveRecord::Migration[6.0]
+ def change
+ add_column :casa_cases, :active, :boolean, default: true, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e30b3772cf..37963f1ce9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -67,6 +67,7 @@
t.boolean "court_report_submitted", default: false, null: false
t.datetime "court_date"
t.datetime "court_report_due_date"
+ t.boolean "active", default: true, null: false
t.bigint "hearing_type_id"
t.bigint "judge_id"
t.index ["casa_org_id"], name: "index_casa_cases_on_casa_org_id"
diff --git a/spec/system/admin_edit_volunteer_spec.rb b/spec/system/admin_edit_volunteer_spec.rb
index e7288e9fdd..24369aaed5 100644
--- a/spec/system/admin_edit_volunteer_spec.rb
+++ b/spec/system/admin_edit_volunteer_spec.rb
@@ -67,4 +67,14 @@
expect(inactive_volunteer.reload).to be_active
end
+
+ context "with a deactivated case" do
+ it "displays inactive message" do
+ deactivated_casa_case = create(:casa_case, active: false, volunteers: [volunteer])
+ sign_in admin
+
+ visit edit_volunteer_path(volunteer)
+ expect(page).to have_text "Case was deactivated on: #{deactivated_casa_case.updated_at.strftime("%m-%d-%Y")}"
+ end
+ end
end
diff --git a/spec/system/admin_edits_a_case_spec.rb b/spec/system/admin_edits_a_case_spec.rb
index 421bc38403..f80caf4872 100644
--- a/spec/system/admin_edits_a_case_spec.rb
+++ b/spec/system/admin_edits_a_case_spec.rb
@@ -8,8 +8,11 @@
let!(:school) { create(:contact_type, name: "School", contact_type_group: contact_type_group) }
let!(:therapist) { create(:contact_type, name: "Therapist", contact_type_group: contact_type_group) }
- it "clicks back button after editing case" do
+ before do
sign_in admin
+ end
+
+ it "clicks back button after editing case" do
visit edit_casa_case_path(casa_case)
check "Court report submitted"
has_checked_field? :court_report_submitted
@@ -20,7 +23,6 @@
end
it "edits case" do
- sign_in admin
visit casa_case_path(casa_case.id)
click_on "Edit Case Details"
has_no_checked_field? :court_report_submitted
@@ -33,5 +35,37 @@
expect(page).to have_text("Day")
expect(page).to have_text("Month")
expect(page).to have_text("Year")
+ expect(page).not_to have_text("Deactivate Case")
+ end
+
+ it "deactivates a case" do
+ visit edit_casa_case_path(casa_case)
+
+ click_on "Deactivate CASA Case"
+ page.driver.browser.switch_to.alert.accept
+
+ expect(page).to have_text("Case #{casa_case.case_number} has been deactivated")
+ expect(page).to have_text("Case was deactivated on: #{casa_case.updated_at.strftime("%m-%d-%Y")}")
+ expect(page).to have_text("Reactivate CASA Case")
+ expect(page).to_not have_text("Court Date")
+ expect(page).to_not have_text("Court Report Due Date")
+ expect(page).to_not have_text("Day")
+ expect(page).to_not have_text("Month")
+ expect(page).to_not have_text("Year")
+ end
+
+ it "reactivates a case" do
+ visit edit_casa_case_path(casa_case)
+ click_on "Deactivate CASA Case"
+ page.driver.browser.switch_to.alert.accept
+ click_on "Reactivate CASA Case"
+
+ expect(page).to have_text("Case #{casa_case.case_number} has been reactivated.")
+ expect(page).to have_text("Deactivate CASA Case")
+ expect(page).to have_text("Court Date")
+ expect(page).to have_text("Court Report Due Date")
+ expect(page).to have_text("Day")
+ expect(page).to have_text("Month")
+ expect(page).to have_text("Year")
end
end
diff --git a/spec/system/supervisor_edits_case_spec.rb b/spec/system/supervisor_edits_case_spec.rb
index cd8e4d84af..12f82d5fd2 100644
--- a/spec/system/supervisor_edits_case_spec.rb
+++ b/spec/system/supervisor_edits_case_spec.rb
@@ -82,4 +82,18 @@
expect(page).to have_text("Court date was not a valid date.")
expect(page).to have_text("Court report due date was not a valid date.")
end
+
+ it "views deactivated case" do
+ casa_case.deactivate
+ visit edit_casa_case_path(casa_case)
+
+ expect(page).to have_text("Case was deactivated on: #{casa_case.updated_at.strftime("%m-%d-%Y")}")
+ expect(page).not_to have_text("Court Date")
+ expect(page).not_to have_text("Court Report Due Date")
+ expect(page).not_to have_text("Day")
+ expect(page).not_to have_text("Month")
+ expect(page).not_to have_text("Year")
+ expect(page).not_to have_text("Reactivate Case")
+ expect(page).not_to have_text("Update Casa Case")
+ end
end
diff --git a/spec/system/volunteer_edits_case_spec.rb b/spec/system/volunteer_edits_case_spec.rb
index 6444484be4..99ec5c68e0 100644
--- a/spec/system/volunteer_edits_case_spec.rb
+++ b/spec/system/volunteer_edits_case_spec.rb
@@ -35,6 +35,7 @@
expect(page).not_to have_text("Day")
expect(page).not_to have_text("Month")
expect(page).not_to have_text("Year")
+ expect(page).not_to have_text("Deactivate Case")
visit casa_case_path(casa_case)
expect(page).to have_text("Court Report Submission: Submitted")
|