Skip to content

Commit

Permalink
Merge pull request #5220 from Iverick/remove-assigned-to-column-from-…
Browse files Browse the repository at this point in the history
…my-casa-table-for-volunteers

Removed "Assigned To" column from My Cases table for volunteers
  • Loading branch information
FireLemons authored Sep 20, 2023
2 parents d1f95a5 + 3971200 commit 5e65c9f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
21 changes: 10 additions & 11 deletions app/views/casa_cases/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
<th>Judge</th>
<th>Status</th>
<th>Transition Aged Youth</th>
<th>Assigned To</th>
<% unless current_user.volunteer? %>
<th>Assigned To</th>
<% end %>
<th></th>
</tr>
</thead>
Expand All @@ -80,20 +82,17 @@
<td class="min-width"><%= casa_case.judge_name %></td>
<td class="min-width"><%= casa_case.decorate.status %></td>
<td class="min-width"><%= casa_case.decorate.transition_aged_youth %></td>
<td class="min-width">
<% if casa_case.active? %>
<% if current_user.volunteer? %>
<%= safe_join(casa_case.assigned_volunteers.map { |vol|
vol.display_name }, ", ") %>
<% else %>
<% unless current_user.volunteer? %>
<td class="min-width">
<% if casa_case.active? %>
<%= safe_join(casa_case.assigned_volunteers.map { |vol|
link_to(vol.display_name, edit_volunteer_path(vol)) },
", ") %>
<% else %>
Case was deactivated on: <%= I18n.l(casa_case.updated_at, format: :standard, default: nil) %>
<% end %>
<% else %>
Case was deactivated on: <%= I18n.l(casa_case.updated_at, format: :standard, default: nil) %>
<% end %>
</td>
</td>
<% end %>
<td>
<i class="lni lni-pencil-alt text-danger"></i>
<%= link_to "Edit", edit_casa_case_path(casa_case), class: 'text-danger' %>
Expand Down
25 changes: 21 additions & 4 deletions spec/system/dashboard/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

RSpec.describe "dashboard/show", type: :system do
let(:volunteer) { create(:volunteer, display_name: "Bob Loblaw") }
let(:casa_admin) { create(:casa_admin, display_name: "John Doe") }

context "volunteer user" do
before do
sign_in volunteer
Expand All @@ -21,15 +23,13 @@
expect(page).not_to have_text(casa_case_3.case_number)
end

it "sees volunteer names in Cases table as plain text" do
it "volunteer does not see his name in Cases table" do
casa_case = build(:casa_case, active: true, casa_org: volunteer.casa_org, case_number: "CINA-1")
create(:case_assignment, volunteer: volunteer, casa_case: casa_case)

visit casa_cases_path

expect(page).to have_text("Bob Loblaw")
expect(page).to have_no_link("Bob Loblaw")
expect(page).to have_css("td", text: "Bob Loblaw")
expect(page).not_to have_css("td", text: "Bob Loblaw")
end

it "displays 'No active cases' when they don't have any assignments", js: true do
Expand All @@ -39,4 +39,21 @@
expect(page).not_to have_text("Detail View")
end
end

context "admin user" do
before do
sign_in casa_admin
end

it "sees volunteer names in Cases table as a link" do
casa_case = build(:casa_case, active: true, casa_org: volunteer.casa_org, case_number: "CINA-1")
create(:case_assignment, volunteer: volunteer, casa_case: casa_case)

visit casa_cases_path

expect(page).to have_text("Bob Loblaw")
expect(page).to have_link("Bob Loblaw")
expect(page).to have_css("td", text: "Bob Loblaw")
end
end
end
18 changes: 18 additions & 0 deletions spec/views/casa_cases/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
require "rails_helper"

RSpec.describe "casa_cases/index", type: :view do
context "when accessed by a volunteer" do
it "can not see the Assigned To column" do
user = create(:volunteer, display_name: "Bob Loblaw")
enable_pundit(view, user)
allow(view).to receive(:current_user).and_return(user)

casa_case = build(:casa_case, active: true, casa_org: user.casa_org, case_number: "CINA-1")
create(:case_assignment, volunteer: user, casa_case: casa_case)
assign :casa_cases, [casa_case]
assign :duties, OtherDuty.none

render template: "casa_cases/index"

expect(rendered).not_to have_text "Assigned To"
expect(rendered).not_to have_text("Bob Loblaw")
end
end

context "when accessed by an admin" do
it "can see the New Case button" do
organization = create(:casa_org)
Expand Down

0 comments on commit 5e65c9f

Please sign in to comment.