forked from rubyforgood/casa
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rubyforgood#4253 from rubyforgood/issue4223-add_ba…
…nner_after_case_contact_creation
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Helper methods for court_dates | ||
module CourtDatesHelper | ||
def when_do_we_have_court_dates(casa_case) | ||
return if casa_case.blank? | ||
|
||
court_dates = casa_case.court_dates.ordered_ascending | ||
date_now = Date.current | ||
|
||
return if court_dates.blank? | ||
|
||
if court_dates.last.date < date_now | ||
"past" | ||
elsif court_dates.first.date > date_now | ||
"future" | ||
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
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,25 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CourtDatesHelper do | ||
describe "#when_do_we_have_court_dates" do | ||
subject { helper.when_do_we_have_court_dates(casa_case) } | ||
|
||
describe "when casa case has only dates in the past" do | ||
let(:casa_case) { create(:casa_case, :with_past_court_date) } | ||
|
||
it { expect(subject).to eq("past") } | ||
end | ||
|
||
describe "when casa case only has dates in the future" do | ||
let(:casa_case) { create(:casa_case, :with_upcoming_court_date) } | ||
|
||
it { expect(subject).to eq("future") } | ||
end | ||
|
||
describe "when casa case has dates both in the past and future" do | ||
let(:casa_case) { create(:casa_case, :with_upcoming_court_date, :with_past_court_date) } | ||
|
||
it { expect(subject).to be_nil } | ||
end | ||
end | ||
end |