-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5534 from sarvaiyanidhi/display-assigned-volunteer
Display Volunteer name next to Case Number
- Loading branch information
Showing
10 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% unless @current_user.volunteer? %> | ||
<span class="badge badge-pill light-bg text-black fs-6 fw-medium"> | ||
<% if @casa_case.assigned_volunteers.present? %> | ||
<%= @casa_case.assigned_volunteers.map(&:display_name).join(", ") %> | ||
<% else %> | ||
Unassigned | ||
<% end %> | ||
</span> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AssignedVolunteersComponent < ViewComponent::Base | ||
def initialize(casa_case, current_user) | ||
@casa_case = casa_case | ||
@current_user = current_user | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe AssignedVolunteersComponent, type: :component do | ||
let(:casa_case) { create(:casa_case) } | ||
let(:current_user) { create(:user) } | ||
|
||
context "when user is not a volunteer" do | ||
it "renders assigned volunteers" do | ||
volunteer = create(:volunteer) | ||
casa_case.volunteers << volunteer | ||
|
||
component = described_class.new(casa_case, current_user) | ||
render_inline(component) | ||
|
||
expect(page).to have_selector("span.badge", text: volunteer.display_name) | ||
end | ||
|
||
it "renders 'Unassigned' when no volunteers present" do | ||
component = described_class.new(casa_case, current_user) | ||
render_inline(component) | ||
|
||
expect(page).to have_selector("span.badge", text: "Unassigned") | ||
end | ||
end | ||
|
||
context "when user is a volunteer" do | ||
let(:current_user) { create(:volunteer) } | ||
|
||
it "does not render badge" do | ||
component = described_class.new(casa_case, current_user) | ||
render_inline(component) | ||
|
||
expect(page).not_to have_selector("span.badge") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters