-
-
Notifications
You must be signed in to change notification settings - Fork 483
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 #5650 from guswhitten/main
- Loading branch information
Showing
4 changed files
with
71 additions
and
3 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
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,45 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CaseContactPresenter do | ||
let(:organization) { build(:casa_org) } | ||
let(:user) { create(:casa_admin, casa_org: organization) } | ||
let(:case_contacts) { create_list(:case_contact, 5, casa_case: casa_case) } | ||
let(:presenter) { described_class.new(case_contacts) } | ||
|
||
before do | ||
allow_any_instance_of(described_class).to receive(:current_user).and_return(user) | ||
allow_any_instance_of(described_class).to receive(:current_organization).and_return(organization) | ||
end | ||
|
||
describe "#display_case_number" do | ||
context "with transition aged youth" do | ||
let(:casa_case) { create(:casa_case, birth_month_year_youth: 15.years.ago, casa_org: organization) } | ||
|
||
it "displays the case number with correct icon" do | ||
casa_case_id = casa_case.id | ||
case_number = casa_case.case_number | ||
|
||
expect(presenter.display_case_number(casa_case_id)).to eql("🦋 #{case_number}") | ||
end | ||
|
||
it "does not error when case number is nil" do | ||
expect(presenter.display_case_number(nil)).to eql("") | ||
end | ||
end | ||
|
||
context "with non-transition aged youth" do | ||
let(:casa_case) { create(:casa_case, birth_month_year_youth: 12.years.ago, casa_org: organization) } | ||
|
||
it "displays the case number with correct icon" do | ||
casa_case_id = casa_case.id | ||
case_number = casa_case.case_number | ||
|
||
expect(presenter.display_case_number(casa_case_id)).to eql("🐛 #{case_number}") | ||
end | ||
|
||
it "does not error when case number is nil" do | ||
expect(presenter.display_case_number(nil)).to eql("") | ||
end | ||
end | ||
end | ||
end |