Files
growstuff/spec/helpers/home_helper_spec.rb
T
Brenda Wallace 54258de6c4 Refactor home dashboard and related components
- Removed unused styles and helper methods from _garden_layout.scss, _homepage.scss, and overrides.scss.
- Updated _home_dashboard.scss to enhance button styles and added new harvest picker styles.
- Introduced HarvestPicker component for improved harvest recording functionality.
- Refactored home dashboard views to utilize new home_section helper for consistent layout.
- Simplified and optimized existing methods in application_helper.rb, activity.rb, and harvest.rb.
- Removed deprecated homepage_records methods from Activity and Harvest models.
- Updated tests to reflect changes in helper methods and removed obsolete tests.
2026-10-12 19:24:55 +13:00

30 lines
863 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
# Plantings and harvests are dated, not timed, so "today" must not turn into
# "19 hours ago" for someone whose midnight was hours back.
describe HomeHelper do
include ActiveSupport::Testing::TimeHelpers
describe '#ago_in_words' do
around { |example| travel_to(Time.zone.local(2026, 10, 12, 19, 30)) { example.run } }
it 'says today for a date that is today' do
expect(helper.ago_in_words(Date.current)).to eq 'today'
end
it 'says yesterday' do
expect(helper.ago_in_words(Date.current - 1)).to eq 'yesterday'
end
it 'counts days for an older date' do
expect(helper.ago_in_words(Date.current - 5)).to eq '5 days ago'
end
it 'still counts hours for a time' do
expect(helper.ago_in_words(3.hours.ago)).to eq 'about 3 hours ago'
end
end
end