]> git.openstreetmap.org Git - rails.git/commitdiff
Use friendly_date for note disappear description
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 15 Nov 2023 19:36:35 +0000 (19:36 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 15 Nov 2023 19:36:35 +0000 (19:36 +0000)
There's no need to reimplement this in its own helper.

app/helpers/note_helper.rb
app/views/notes/show.html.erb
test/helpers/note_helper_test.rb

index 4e7e37bfb931063d0920b1975f6eb979cf36ad2d..21c8fa51e8c4326cd37182aeda636b4898c15d20 100644 (file)
@@ -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
index 3bb97b484289396ffeec14167cff936401c52ad0..fda8946b6b18378ce483c53c0bf267963d5f3df2 100644 (file)
@@ -95,7 +95,7 @@
 
   <% if @note.freshly_closed? %>
     <small class="text-muted">
-      <%= t ".disappear_date_html", :disappear_in => disappear_in(@note) %>
+      <%= t ".disappear_date_html", :disappear_in => friendly_date(@note.freshly_closed_until) %>
     </small>
   <% end %>
 </div>
index 4f36f91759cb9a39dfca78b8347637f1257ac11f..bee1cdc2c5485291cf52cdfb5d09e3b0520ee6cd 100644 (file)
@@ -21,13 +21,4 @@ class NoteHelperTest < ActionView::TestCase
     assert_equal "<a href=\"/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user)
     assert_equal "<a href=\"http://test.host/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", 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{^<span title=" 8 January 2022 at 12:00">6 days</span>$}, disappear_in(note)
-    end
-  end
 end