Project

General

Profile

Patch #38139 ยป add-guard-clause-to-time-tag.patch

Go MAEDA, 2023-01-01 07:42

View differences:

app/helpers/application_helper.rb
end
def time_tag(time)
return if time.nil?
text = distance_of_time_in_words(Time.now, time)
if @project
link_to(text,
test/helpers/application_helper_test.rb
end
end
def test_time_tag
user = User.find(1)
user.pref.update(time_zone: 'UTC')
User.current = user
assert_nil time_tag(nil)
with_locale 'en' do
travel_to Time.zone.parse('2022-12-30T01:00:00Z') do
assert_equal "<abbr title=\"12/28/2022 01:00 AM\">2 days</abbr>", time_tag(2.days.ago)
@project = Project.find(1)
assert_equal "<a title=\"12/28/2022 01:00 AM\" href=\"/projects/ecookbook/activity?from=2022-12-28\">2 days</a>", time_tag(2.days.ago)
end
end
end
private
def wiki_links_with_special_characters
    (1-1/1)