From: Andy Allan Date: Wed, 15 Nov 2023 19:36:35 +0000 (+0000) Subject: Use friendly_date for note disappear description X-Git-Tag: live~991^2~4 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/100a7f8979023a2265c9fa58e6bed317b5937670 Use friendly_date for note disappear description There's no need to reimplement this in its own helper. --- diff --git a/app/helpers/note_helper.rb b/app/helpers/note_helper.rb index 4e7e37bfb..21c8fa51e 100644 --- a/app/helpers/note_helper.rb +++ b/app/helpers/note_helper.rb @@ -21,9 +21,4 @@ module NoteHelper link_to h(author.display_name), link_options.merge(:controller => "/users", :action => "show", :display_name => author.display_name) end end - - def disappear_in(note) - date = note.freshly_closed_until - tag.span(distance_of_time_in_words(date, Time.now.utc), :title => l(date, :format => :friendly)) - end end diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 3bb97b484..fda8946b6 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -95,7 +95,7 @@ <% if @note.freshly_closed? %> - <%= t ".disappear_date_html", :disappear_in => disappear_in(@note) %> + <%= t ".disappear_date_html", :disappear_in => friendly_date(@note.freshly_closed_until) %> <% end %> diff --git a/test/helpers/note_helper_test.rb b/test/helpers/note_helper_test.rb index 4f36f9175..bee1cdc2c 100644 --- a/test/helpers/note_helper_test.rb +++ b/test/helpers/note_helper_test.rb @@ -21,13 +21,4 @@ class NoteHelperTest < ActionView::TestCase assert_equal "#{user.display_name}", note_author(user) assert_equal "#{user.display_name}", note_author(user, :only_path => false) end - - def test_disappear_in - note_closed_date = Time.utc(2022, 1, 1, 12, 0, 0) - note = create(:note, :closed_at => note_closed_date) - - travel_to note_closed_date + 1.day do - assert_match %r{^6 days$}, disappear_in(note) - end - end end