Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2115] Allow unsetting judge on a given CASA case #2136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/casa_cases/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
) %>
</div>
Expand Down
42 changes: 42 additions & 0 deletions spec/system/casa_cases/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down