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

Support a due "Tommorow at time" string for short term loans that are… #605

Merged
merged 1 commit into from
Oct 13, 2020
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
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def active_page_class(name)
# For short-term loans, also include the time.
def today_with_time_or_date(date, short_term: false)
return l(date, format: :time_today) if short_term && date.today?
return l(date, format: :time_tomorrow) if short_term && date.to_date == Time.zone.tomorrow

format_human_readable_date(date)
end
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ en:
short: '%B %e, %Y'
long: '%B %e, %Y %l:%M%P'
time_today: 'Today at %-l:%M%P'
time_tomorrow: 'Tomorrow at %-l:%M%P'
hello: "Hello world"
mylibrary:
renew_item:
Expand Down
7 changes: 7 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
.to match(/^Today at\s{1,2}\d/)
end

it 'returns a string that says Tomorrow and the time' do
date = Time.zone.tomorrow.at_end_of_day

expect(helper.today_with_time_or_date(date, short_term: true))
.to match(/^Tomorrow at\s{1,2}\d/)
end

context 'when the due date is on a past date' do
it 'returns a formatted date' do
expect(
Expand Down