]> git.openstreetmap.org Git - rails.git/commitdiff
Report deactivates_at as block read date
authorAnton Khorev <tony29@yandex.ru>
Tue, 7 Jan 2025 10:19:33 +0000 (13:19 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 7 Jan 2025 10:19:33 +0000 (13:19 +0300)
app/helpers/user_blocks_helper.rb
test/helpers/user_blocks_helper_test.rb

index 75bd4a46daec8b1ce277f0b01e59f8f2e3f7cf8d..f18a6250c9e556f65892b30eca7691fd2e6f1ba4 100644 (file)
@@ -35,7 +35,7 @@ module UserBlocksHelper
     else
       if block.revoker_id.nil?
         if block.deactivates_at > block.ends_at
-          t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.updated_at))
+          t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.deactivates_at))
         else
           t("user_blocks.helper.short.ended")
         end
index 28cc0ad5055cdd530a861164d5c8bc3a87592c1c..d308f46ead1cc04cc9dbf0ed806a431824f0ce2d 100644 (file)
@@ -58,7 +58,16 @@ class UserBlocksHelperTest < ActionView::TestCase
 
       block.update(:needs_view => false, :deactivates_at => Time.now.utc)
 
-      assert_match "read at", block_short_status(block)
+      read_date = Time.now.utc.to_date.strftime
+      short_status_dom = Rails::Dom::Testing.html_document.parse(block_short_status(block))
+      assert_dom short_status_dom, ":root", :text => "read at #{read_date}"
+
+      travel 24.hours
+
+      block.update(:reason => "updated reason")
+
+      short_status_dom = Rails::Dom::Testing.html_document.parse(block_short_status(block))
+      assert_dom short_status_dom, ":root", :text => "read at #{read_date}"
     end
   end