diff --git a/app/views/casa_cases/_form.html.erb b/app/views/casa_cases/_form.html.erb
index 712708acde..4b6dd54d28 100644
--- a/app/views/casa_cases/_form.html.erb
+++ b/app/views/casa_cases/_form.html.erb
@@ -52,7 +52,7 @@
:judge_id,
Judge.for_organization(current_organization),
:id, :name,
- {include_hidden: false, prompt: t(".prompt.select_judge")},
+ {include_hidden: false, include_blank: t(".prompt.select_judge")},
{class: "form-control"}
) %>
diff --git a/spec/system/casa_cases/edit_spec.rb b/spec/system/casa_cases/edit_spec.rb
index f7285cf9c8..86de3bc2c0 100644
--- a/spec/system/casa_cases/edit_spec.rb
+++ b/spec/system/casa_cases/edit_spec.rb
@@ -162,6 +162,48 @@
expect(page).to have_text("8-SEP-#{next_year}")
end
+ context "with an available judge" do
+ let!(:judge) { create(:judge, casa_org: casa_org) }
+
+ it "is able to assign a judge to the case when there is no assigned judge", js: true do
+ casa_case.update(judge: nil)
+
+ visit edit_casa_case_path(casa_case)
+
+ expect(page).to have_select("Judge", selected: "-Select Judge-")
+ select judge.name, from: "casa_case_judge_id"
+
+ click_on "Update CASA Case"
+
+ expect(page).to have_select("Judge", selected: judge.name)
+ expect(casa_case.reload.judge).to eq judge
+ end
+
+ it "is able to assign another judge to the case", js: true do
+ visit edit_casa_case_path(casa_case)
+
+ expect(page).to have_select("Judge", selected: casa_case.judge.name)
+ select judge.name, from: "casa_case_judge_id"
+
+ click_on "Update CASA Case"
+
+ expect(page).to have_select("Judge", selected: judge.name)
+ expect(casa_case.reload.judge).to eq judge
+ end
+
+ it "is able to unassign a judge from the case", js: true do
+ visit edit_casa_case_path(casa_case)
+
+ expect(page).to have_select("Judge", selected: casa_case.judge.name)
+ select "-Select Judge-", from: "casa_case_judge_id"
+
+ click_on "Update CASA Case"
+
+ expect(page).to have_select("Judge", selected: "-Select Judge-")
+ expect(casa_case.reload.judge).to be_nil
+ end
+ end
+
it "will return error message if date fields are not fully selected" do
visit casa_case_path(casa_case)
expect(page).to have_text("Court Report Status: Not submitted")