Skip to content

Fix usage of distance_of_time_in_words_to_now

Summary

Issue created from @leipert's comment: #336230 (comment 631199866).

It seems like distance_of_time_in_words_to_now is used in several other places as well, which we should fix in a follow-up as well!

app/controllers/concerns/membership_actions.rb
29:                      expires_in: helpers.distance_of_time_in_words_to_now(member.expires_at),

app/controllers/groups/group_links_controller.rb
32:        expires_in: helpers.distance_of_time_in_words_to_now(@group_link.expires_at),

app/views/shared/members/_member.html.haml
48:                = _("Expires in %{expires_at}").html_safe % { expires_at: distance_of_time_in_words_to_now(member.expires_at) }

app/views/shared/deploy_tokens/_table.html.haml
23:                  In #{distance_of_time_in_words_to_now(token.expires_at)}

app/views/shared/access_tokens/_table.html.haml
50:                    = _('In %{time_to_now}') % { time_to_now: distance_of_time_in_words_to_now(token.expires_at) }

app/controllers/projects/group_links_controller.rb
31:        expires_in: helpers.distance_of_time_in_words_to_now(group_link.expires_at),

app/views/admin/system_info/show.html.haml
34:        %h2= distance_of_time_in_words_to_now(Rails.application.config.booted_at)

Each of these instances should be changed to use time_ago_with_tooltip instead, because distance_of_time_in_words_to_now does not respect the User#time_display_relative setting.

Steps to reproduce

Example Project

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes